Thank you for your Quick response Michael.
I will try to follow your suggestions
I will be back soon with my results

There is another API Frameworks.getPlanner() which does something similar
Planner planner = Frameworks.getPlanner(config);
SqlNode parsed = planner.parse("SELECT * FROM MYTABLE");
RelRoot rel = planner.rel(parsed);


I will have to deal with:
- schema changes
- caching plans
- multiple schemas
- indexes/costs based planer

Do you (or any one else) have some links to test cases or other usages of
Calcite as planner ?

Cheers
-- Enrico



2017-09-26 17:27 GMT+02:00 Michael Mior <mm...@uwaterloo.ca>:

> 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
> mm...@apache.org
>
> 2017-09-26 10:36 GMT-04:00 Enrico Olivelli <eolive...@gmail.com>:
>
> > 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
> > eolive...@apache.org
> >
>

Reply via email to