Skip to content


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 to visitExpression
  • DefaultKsqlParser is requested to prepare
  • ExpressionParser is requested to parseSelectExpression, 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:

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)
  1. 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:

Back to top