[ 
https://issues.apache.org/jira/browse/IMPALA-7914?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16719233#comment-16719233
 ] 

ASF subversion and git services commented on IMPALA-7914:
---------------------------------------------------------

Commit 80a4e6d3187d4dde6381e229cd409aa8ab13d9b7 in impala's branch 
refs/heads/master from [~paul-rogers]
[ https://git-wip-us.apache.org/repos/asf?p=impala.git;h=80a4e6d ]

IMPALA-7914: Base class for statement-like AST nodes

In order to integrate expression rewrites into the analysis phase, the
expression analyze() operation must be able to replace one expression
node with another. Statements, however, are analyzed in place. The two
types of parse nodes thus need different analyze() semantics.

To prepare for that goal, this patch introduces a new StmtNode class
as the base for all statement-like AST nodes. The existing analyze()
method moves to StmtNode. While Expr still defines this method for now,
the future goal is to change the Expr analyze() semantics.

Tests: This is purely a code restructuring, no functional changes. Reran
all FE tests.

Change-Id: Ie565ff02ad74f805a667017ba9bc8c0a2697a97b
Reviewed-on: http://gerrit.cloudera.org:8080/12018
Reviewed-by: Impala Public Jenkins <[email protected]>
Tested-by: Impala Public Jenkins <[email protected]>


> Introduce AST base class/interface for statement-like nodes
> -----------------------------------------------------------
>
>                 Key: IMPALA-7914
>                 URL: https://issues.apache.org/jira/browse/IMPALA-7914
>             Project: IMPALA
>          Issue Type: Improvement
>          Components: Frontend
>    Affects Versions: Impala 3.0
>            Reporter: Paul Rogers
>            Assignee: Paul Rogers
>            Priority: Minor
>
> The front-end is based on an abstract syntax tree (AST). The parser creates 
> the AST, the analyzer decorates it with semantic information, and the planner 
> creates a plan for it.
> At present, the class hierarchy looks like this:
> {noformat}
> ParseNode
> |-- Expr
> |   |-- <all expression nodes>
> |-- FromClause
> |-- <other statment fragments>
> |-- StatementBase
> |   |-- SelectStmt
> |   |-- <other statements>
> {noformat}
> This is a nuisance because the only common base class for all statement-like 
> nodes is the {{ParseNode}}, which is also the common base class or 
> expressions. However, expressions and statement-like nodes behave differently 
> during analysis, SQL generation, and so on.
> We propose to refactor the tree to introduce a new {{StmtNode}} interface or 
> class that defines the statement-like semantics, leaving {{Expr}} to define 
> the expression-like semantics. The methods then move out of {{ParseNode}}.
> This change all allow revising the analysis step as follows:
> * Analysis of statement-like nodes is done "in place"
> * Analysis of expression nodes may result in replacing one node with a 
> rewritten version
> Similarly, when generating SQL:
> * Statements provide the option of generating before- or after-rewrite SQL.
> * Expressions can only generate SQL for what they are; they have no concept 
> of before- or after- rewrites.
> Specifically:
> {noformat}
> ParseNode
> |-- Expr
> |   |-- <all expression nodes>
> |-- StmtNode
> |   |-- FromClause
> |   |-- <other statment fragments>
> |   |-- StatementBase
> |   |   |-- SelectStmt
> |   |   |-- <other statements>
> {noformat}
> It may be useful to introduce a {{ClauseNode}}, but we'll see if that is 
> actually helpful as we do the refactoring:
> {noformat}
> |-- StmtNode
> |   |-- ClauseNode
> |   |   |-- FromClause
> |   |   |-- <other statment fragments>
> |   |-- StatementBase
> |   |   |-- SelectStmt
> |   |   |-- <other statements>
> {noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to