There seems to be no easy way to do this, you can take look at Hive, it
uses its own parser to parse SQL and use Caclite to do the optimization.
By the way, Calcite's parser is quite OK both in compatibility and
performance(javacc is faster than Antlr), in Bytedance, we use Calcite to
do the federate SQL engine, and it works well, my suggestion is to use
calcite own parser unless you've already done this part.

If you have to do this, you can either generate SqlNode with Antlr OR
transform your own AST tree to RelNode, you can take a look
at org.apache.calcite.sql2rel.SqlToRelConverter.

I have blogs for Calcite's parser/optimizer(in Chinese), maybe you can take
a look :)

Calcite parser:
https://aaaaaaron.github.io/2020/02/08/Calcite-Parser-%E9%83%A8%E5%88%86/
Calcite volcano planner:
https://aaaaaaron.github.io/2020/02/08/Calcite-Volcano-Optimizer-%E9%83%A8%E5%88%86/


Regards!

Aron Tao


Juan Pan <panj...@apache.org> 于2020年11月22日周日 下午2:32写道:

> Hi community,
>
>
>
>
> Thanks for your attention. : )
>
>
>
>
> Currently, Apache ShardingSphere community plans to leverage Apache
> Calcite to implement federated SQL query,
>
> i.e., the query from different database instances [1].
>
>
>
>
> The draft approach is that we consider using the custom adaptor with the
> SQL parser of ShardingSphere itself (Antlr involved),
>
> and transforming the parsed result to the algebra of Calcite.
>
>  Lastly, Calcite will execute the SQLs by means of the custom adaptor.
>
>
>
>
> Currently, I know the entrance of calling the custom adaptor is to use the
> `DriverManager.getConnection(CalciteUrl)`, which will get Calcite's SQL
> parsing involved.
>
> But we want to avoid twice SQL parsing, which means we wish to ignore the
> SQL parsing of CalciteN .
>
>
>
>
> My question is that how we can leverage Calcite adaptor without using
> Calcite parser.
>
> Could you give me some hints?
>
>
>
>
> Very appreciated your any help and reply.
>
>
>
>
> Regards,
>
> Trista
>
>
>
>
>
>
>
> [1] https://github.com/apache/shardingsphere/issues/8284
>
>
>
>  Juan Pan (Trista)
>
> Senior DBA & PMC of Apache ShardingSphere
> E-mail: panj...@apache.org
>
>
>
>

Reply via email to