Skip to content

AstBuilder.Visitor

Visitor is a SqlBaseBaseVisitor to build a Node tree (that AstBuilder uses to build a parsed tree).

ANTLR

SqlBaseBaseVisitor is generated from SqlBase.g4 SQL grammar by ANTLR at build time.

Creating Instance

Visitor takes the following to be created:

  • Source Names
  • TypeRegistry

Visitor is created when:

Parsing Statements

ASSERT TABLE

Node visitAssertTable(
  AssertTableContext context)

visitAssertTable is part of the SqlBaseBaseVisitor abstraction to handle ASSERT TABLE statements:

ASSERT TABLE sourceName
(tableElements)?
(WITH tableProperties)?

visitAssertTable creates an AssertTable with a CreateTable.

CREATE STREAM

Node visitCreateStream(
  SqlBaseParser.CreateStreamContext context)

visitCreateStream is part of the SqlBaseBaseVisitor abstraction to handle CREATE STREAM statements:

CREATE (OR REPLACE)? (SOURCE)? STREAM (IF NOT EXISTS)? sourceName
(tableElements)?
(WITH tableProperties)?

tableElements
    : '(' tableElement (',' tableElement)* ')'
    ;

tableProperties
    : '(' tableProperty (',' tableProperty)* ')'
    ;

visitCreateStream creates an CreateStream.

CREATE TABLE

Node visitCreateTable(
  SqlBaseParser.CreateTableContext context)

visitCreateTable is part of the SqlBaseBaseVisitor abstraction to handle CREATE TABLE statements.

CREATE (OR REPLACE)? (SOURCE)? TABLE (IF NOT EXISTS)? sourceName
(tableElements)?
(WITH tableProperties)?

visitCreateTable creates a CreateTable.

EXPLAIN

Node visitExplain(
  SqlBaseParser.ExplainContext ctx)

visitExplain is part of the SqlBaseBaseVisitor abstraction to handle EXPLAIN statements.

EXPLAIN (statement | identifier)

visitExplain creates an Explain.

INSERT INTO

Node visitInsertInto(
  SqlBaseParser.InsertIntoContext context)

visitInsertInto is part of the SqlBaseBaseVisitor abstraction to handle INSERT INTO statements.

INSERT INTO sourceName (WITH tableProperties)? query

visitInsertInto creates an InsertInto.

visitCreateStreamAs

Node visitCreateStreamAs(
  SqlBaseParser.CreateStreamAsContext context)

visitCreateStreamAs is part of the SqlBaseBaseVisitor abstraction to handle CREATE STREAM AS (CSAS) statements.

CREATE (OR REPLACE)? STREAM (IF NOT EXISTS)? sourceName
  (WITH tableProperties)? AS query

visitCreateStreamAs creates a CreateStreamAsSelect.

visitCreateTableAs

Node visitCreateTableAs(
  SqlBaseParser.CreateTableAsContext context)

visitCreateTableAs is part of the SqlBaseBaseVisitor abstraction to handle CREATE TABLE AS (CTAS) statements.

CREATE (OR REPLACE)? TABLE (IF NOT EXISTS)? sourceName
  (WITH tableProperties)? AS query

visitCreateTableAs creates a CreateTableAsSelect.

visitInsertInto

Node visitInsertInto(
  SqlBaseParser.InsertIntoContext context)

visitInsertInto is part of the SqlBaseBaseVisitor abstraction to handle INSERT INTO statements.

INSERT INTO sourceName (WITH tableProperties)? query

visitInsertInto creates a InsertInto.

SELECT

Query visitQuery(
  SqlBaseParser.QueryContext context)

visitQuery is part of the SqlBaseBaseVisitor abstraction to handle SELECT statements (queries).

query
    : SELECT selectItem (',' selectItem)*
      FROM from=relation
      (WINDOW  windowExpression)?
      (WHERE where=booleanExpression)?
      (GROUP BY groupBy)?
      (PARTITION BY partitionBy)?
      (HAVING having=booleanExpression)?
      (EMIT resultMaterialization)?
      limitClause?
    ;

visitQuery creates a Query.

buildingPersistentQuery Flag

Visitor defines buildingPersistentQuery internal flag that is false when created.

buildingPersistentQuery flag is turned on (true) when withinPersistentQuery.

withinPersistentQuery

T withinPersistentQuery(
  Supplier<T> task)

withinPersistentQuery...FIXME

withinPersistentQuery is used when:

Back to top