Calcite - Sql Parser


The ''calcite SQL Parser is a LL(k) parser that build a Sql tree (SqlNode)


The parserConfig parameters control the parse process.

For example:

  • identifiers (quoted using brackets, or back-ticks or double-quotes),
  • how to treat the case of quoted and unquoted identifiers


To parse specific SQL, you probably need to create:

How to parse a SQL statement

Query planning Utility

As shown in the getting_started, you can parse a SQL with the query planning utility

SqlNode sqlNode = planner.parse("select, count(emps.empid) from emps inner join depts on emps.deptno = depts.deptno group by depts.deptno, order by");


Directly with a SqlParser Object

// Parser config with no case sensitivity (TABLE is the same than table)
SqlParser.Config parserConfig = SqlParser.configBuilder()
// Create
SqlParser parser = SqlParser.create(sql, parserConfig)
// Parse
SqlNode sqlNode = parser.parseStmt() // for a statement
SqlNode sqlNode = parser.parseQuery() // if you known that it's a query

JDBC prepare

See also the Prepare function of JDBC CalcitePrepareImpl#prepare2_ function

Powered by ComboStrap