AstBuilder¶
AstBuilder
uses AstBuilder.Visitor to parse SQL statements (using ANTLR).
Creating Instance¶
AstBuilder
takes the following to be created:
AstBuilder
is created when:
QueryAnonymizer.Visitor
is requested tovisitExpression
DefaultKsqlParser
is requested to prepare a statement for executionExpressionParser
is requested toparseSelectExpression
,parseExpression
,parseWindowExpression
Building Statement¶
Statement buildStatement(
ParserRuleContext parseTree)
buildStatement
collects the source names (in the SQL statement as a parsed tree) first and then builds a Statement.
buildStatement
is used when:
DefaultKsqlParser
is requested to prepare a ParsedStatement
Collecting Source Names¶
Set<SourceName> getSources(
ParseTree parseTree)
getSources
creates a SourceAccumulator to visit (the nodes of) the given ParseTree
. In the end, getSources
requests the SourceAccumulator
for the sources.
Building Node¶
<T extends Node> T build(
Optional<Set<SourceName>> sources, // (1)!
ParserRuleContext parseTree)
sources
are only given for building a Statement
build
creates an AstBuilder.Visitor to build one of the following Nodes (for a given ParserRuleContext
that is a parsed SQL statement):