Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-7914

Introduce AST base class/interface for statement-like nodes

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • Impala 3.0
    • Impala 3.2.0
    • Frontend
    • None
    • ghx-label-6

    Description

      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:

      ParseNode
      |-- Expr
      |   |-- <all expression nodes>
      |-- FromClause
      |-- <other statment fragments>
      |-- StatementBase
      |   |-- SelectStmt
      |   |-- <other statements>
      

      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:

      ParseNode
      |-- Expr
      |   |-- <all expression nodes>
      |-- StmtNode
      |   |-- FromClause
      |   |-- <other statment fragments>
      |   |-- StatementBase
      |   |   |-- SelectStmt
      |   |   |-- <other statements>
      

      It may be useful to introduce a ClauseNode, but we'll see if that is actually helpful as we do the refactoring:

      |-- StmtNode
      |   |-- ClauseNode
      |   |   |-- FromClause
      |   |   |-- <other statment fragments>
      |   |-- StatementBase
      |   |   |-- SelectStmt
      |   |   |-- <other statements>
      

      Attachments

        Activity

          People

            Paul.Rogers Paul Rogers
            Paul.Rogers Paul Rogers
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: