AstBuilder¶
AstBuilder
uses Visitor to parse SQL statements (using ANTLR).
Creating Instance¶
AstBuilder
takes the following to be created:
-
TypeRegistry
AstBuilder
is created when:
QueryAnonymizer.Visitor
is requested tovisitExpression
DefaultKsqlParser
is requested to prepareExpressionParser
is requested toparseSelectExpression
,parseExpression
,parseWindowExpression
Building Statement¶
Statement buildStatement(
ParserRuleContext parseTree)
buildStatement
collects the source names (in a SQL statement) and 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 Parsed Tree (build)¶
<T extends Node> T build(
Optional<Set<SourceName>> sources, // (1)!
ParserRuleContext parseTree)
- Only given when
AstBuilder
is requested to build a Statement
build
creates a Visitor to build a node tree (for a given ParserRuleContext
that represents a parsed SQL text).
build
is used when:
AstBuilder
is requested to build a Statement, an Expression, a WindowExpression and an AssertStatement