calcite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Julian Hyde <jh...@apache.org>
Subject Re: about calcite core design
Date Fri, 11 Dec 2015 19:36:26 GMT
The “coupling” is not for performance. Each AST node (SqlNode) contains a position so that
we can give a good error message, including the exact position of the error, when there is
a validation error. This important if you are running a SQL statement that is more than a
few lines long.

SqlParserPos contains only 4 fields:

   int lineNumber;
   int columnNumber;
   int endLineNumber;
   int endColumnNumber;

We deliberately do not keep references to the parser, or to the tokens emitted by the parser,
or even to the source SQL text. (We used to, by accident, and it caused memory leaks.) So,
you can easily create a SqlParserPos for each node if you have used a different parser. Or
you can just use SqlParserPos.ZERO for every node (if you don’t want meaningful positions
in your error messages).

Julian



> On Dec 10, 2015, at 10:58 PM, xuxuwangzi888 <xuxuwangzi888@163.com> wrote:
> 
> dear,
>      I have a question,why the parser and operator Tree are coupled,like this:
> 
> SqlNode(SqlParserPos pos) {
> 
>  Util.pre(pos != null, "pos != null");
>  this.pos = pos;
> }
> 
> 
>  Because we pass the variable pos,it lead to the couple。
> 
> I develped a parser use antlr,and hope the parse and symantec tree is loose coupled。
> 
>   I guess calcite coupled design is for performance, is it ?   
> 
>   Many thanks!
> 
> gongbo.yxh
> 
> 
> 


Mime
View raw message