You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Homer <lo...@gmail.com> on 2015/11/06 18:59:03 UTC
Correct usage of SqlToRelConverter
Hi,
I am new to calcite and just want to say thanks for building such an
excellent set of tools. I am currently wanting to use an sql front end
to access my specialized query engine and it would appear that calcite
is a great fit.
I built an example like the csv example just to get things working and
that seems fine.
My goal is to use calcite as the sql query parser and optimizer and to
then consume the relational algebra in my query executor. This sounded
simple but I seem to be having difficulties in what I thought would be a
fairly easy step. Currently I can generate the sqlNodes via the parser
but I am having issues creating an instance of an SqlToRelConverter.
A code snippet to help explain:
SqlNode node = processSQL("select col1 from table1");
/*
Do some additional set up for SqlToRelConverter
Create viewExpander
Create validator
Create catalogReader
Create cluster
Create convertletTable
*/
SqlToRelConverter convert = new SqlToRelConverter(viewExpander,
validator, catalogReader, cluster, convertletTable);
Is what I would like to do in the simplest form but I seem to not be
"getting" how to set up those components. Is there something I am
entirely missing here. Is there an example I should be looking more
closely at? I have been looking at SqlToRelTestBase.java, is that the
right place to be modelling from?
Any help would be much appreciated as I don't want to reinvent the wheel
as it seems if I continue down the path I am on I will be duplicating
huge sections of the existing code due to some Implementations not being
public.
I am afraid maybe I am thinking about the calcite model incorrectly.
thanks,
Homer
Re: Correct usage of SqlToRelConverter
Posted by Julian Hyde <jh...@apache.org>.
Have you tried using org.apache.calcite.tools.Planner? It was designed to make it easier to use Calcite from outside a container. PlannerTest has several examples.
http://calcite.apache.org/apidocs/org/apache/calcite/tools/Planner.html
Julian
> On Nov 6, 2015, at 9:59 AM, Homer <lo...@gmail.com> wrote:
>
> Hi,
>
> I am new to calcite and just want to say thanks for building such an excellent set of tools. I am currently wanting to use an sql front end to access my specialized query engine and it would appear that calcite is a great fit.
>
> I built an example like the csv example just to get things working and that seems fine.
>
> My goal is to use calcite as the sql query parser and optimizer and to then consume the relational algebra in my query executor. This sounded simple but I seem to be having difficulties in what I thought would be a fairly easy step. Currently I can generate the sqlNodes via the parser but I am having issues creating an instance of an SqlToRelConverter.
>
> A code snippet to help explain:
>
> SqlNode node = processSQL("select col1 from table1");
>
> /*
> Do some additional set up for SqlToRelConverter
>
> Create viewExpander
> Create validator
> Create catalogReader
> Create cluster
> Create convertletTable
> */
>
> SqlToRelConverter convert = new SqlToRelConverter(viewExpander,
> validator, catalogReader, cluster, convertletTable);
>
>
> Is what I would like to do in the simplest form but I seem to not be "getting" how to set up those components. Is there something I am entirely missing here. Is there an example I should be looking more closely at? I have been looking at SqlToRelTestBase.java, is that the right place to be modelling from?
>
> Any help would be much appreciated as I don't want to reinvent the wheel as it seems if I continue down the path I am on I will be duplicating huge sections of the existing code due to some Implementations not being public.
>
> I am afraid maybe I am thinking about the calcite model incorrectly.
>
> thanks,
> Homer