calcite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Muhammad Gelbana <>
Subject Re: Type information from SQL parser?
Date Wed, 05 Jun 2019 23:14:18 GMT
Parsing alone can't get you types. You'll have to validate (let Calcite
discover your schemas, tables and columns metadata). A quick look in
SqlNode showed no trace of types information (other than the SqlKind
enumeration which doesn't seem like what you're looking for).

Therefore I believe you'll have to convert the SqlNode tree to RelNode.
Sample code:

Planner planner = Frameworks.getPlanner(frameworkConfig);
SqlNode parsed = planner.parse(query);
SqlNode validated = planner.validate(parsed);
RelRoot root = planner.rel(validated); // Convert SqlNode tree to RelNode

"root.rel" should have what you need.


On Thu, Jun 6, 2019 at 12:02 AM Scott McKinney <>

> Hi.  I'm reviewing Calcite for a project and I'm having difficulty wading
> through the API. Roughly, I want the following functionality from the
> Calcite API:
> var schema = parseDDL(RAW_DDL); // SQL DDL or any type of Calcite
> supported schema
> var query = parseQuery("SELECT c1, c2 FROM t1 WHERE c2='value'", schema);
> var selectFields = query.getSelectFields();for(var field: selectFields) {
>   var name = field.getName();
>   var type = field.getType(); // <~~~ want this in terms of `t1` from ddl
>   ...}
> The type information for the select list in terms of the tables etc. in the
> DDL is what I'm after.
> Is this possible?  Thanks!

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message