Calcite - Sql Parser

Card Puncher Data Processing


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

Discover More
Card Puncher Data Processing
Calcite (Farrago, Optiq)

Calcite is a Java SQL Processing engine where the data storage is developed in plugin. Calcite is an open source cost based query optimizer and query execution framework. SQL Parser SQL Validation...
Card Puncher Data Processing
Calcite - Getting Started (from Sql to Resultset)

A getting started page that shows a query planning process (ie from sql to resultset process) gerardnico/calcite/blob/master/src/test/java/com/gerardnico/calcite/
Card Puncher Data Processing
Calcite - Query Planning Process (Sql Processing)

in Calcite The query planning process is the entire process that takes a SQL to a result. The process can be resumed as follow: Phase 1: The Sql statement (Query) is parsed to build a parse tree...
Card Puncher Data Processing
Calcite - Syntax Tree (SqlNode)

SQL tree in Calcite. The tree is build by the parser and each node (Tokens) is represented by SqlNode SqlNode can be converted back to SQL via the unparse...
Oracle Database Sql Processing
SQL Engine - SQL Parser

The parser in an SQL engine parse a Sql statement. It's the first stage of SQL processing. This stage involves separating the pieces of a SQL statement into a SQL Tree where each node is a SQL token...

Share this page:
Follow us:
Task Runner