That's definitely possible and is definitely the kind of use case Calcite
is designed for. In terms of Calcite APIs, the approach would be something
like the following:

Use SqlParser to get a SqlNode representing the query
Implement CatalogReader to provide access to the schema
Convert the SqlNode to a RelNode (relational algebra expression) using
SqlToRelConverter
Construct a RelOptPlanner instance and set the root of your planner to the
RelNode from your query
Call findBestExp on the planner and then walk the generated expression tree
to generate a HerdDB plan

This can hopefully get you pointed in the right direction. Personally, I'm
not sure how you would best incorporate the use of indexes, but I'm sure
someone else will be able to chime in.

Cheers,
--
Michael Mior
[email protected]

2017-09-26 10:36 GMT-04:00 Enrico Olivelli <[email protected]>:

> Hi,
> I would like to use Calcite as SQLPlanner in my open source project HerdDB
> https://github.com/diennea/herddb
>
> HerdDB is a distributed database built in Java, it is essentially a
> distributed key-value store but is has an SQL layer which is the entrypoint
> for JDBC clients.
>
> Currently we have a very simple SQLPlanner, that is a component which maps
> SQL language to an internal AST which represents the access plan to data.
>
> I heard about Calcite and as far as I can see it would be easy to integrate
> Calcite as SQL Planner.
>
>
> I am expecting to have something like this:
> 1) Give to Calcite an SQL query  + Current schema + available indexes....
> 2) Calcite which creates a access plan using Calcite AST
> 3) Convert Calcite AST to HerdDB access plan AST
>
> I am not looking at something on the client-side I would like to use
> Calcite on the server
> is is possible ?
>
> Thank you in advance
>
> Enrico Olivelli
> [email protected]
>

Reply via email to