Hi Amogh,

[1] is a very simple example of using Calcite framework. I wrote it
following Drill's planner Jacques mentioned above. Below is the basic
process of converting a query into a plan:

1. Parse the query [2]
2. Validate the query. You can check for unsupported operators, etc. at
this phase. [3]
3. Then you can convert the SqlNode (parsed output) to a RelNode [4]
4. After that you can apply what ever the rules to transform the logical
plan [5]. In [1] I transformed it to an our own RelNode implementation.

Hope above helps. I have never seen the error you mentioned above.

Milinda

[1]
https://github.com/milinda/samza/blob/rb34664/samza-sql-calcite/src/main/java/org/apache/samza/sql/planner/QueryPlanner.java
[2]
https://github.com/milinda/samza/blob/rb34664/samza-sql-calcite/src/main/java/org/apache/samza/sql/planner/QueryPlanner.java#L98
[3]
https://github.com/milinda/samza/blob/rb34664/samza-sql-calcite/src/main/java/org/apache/samza/sql/planner/QueryPlanner.java#L156
[4]
https://github.com/milinda/samza/blob/rb34664/samza-sql-calcite/src/main/java/org/apache/samza/sql/planner/QueryPlanner.java#L132
[5]
https://github.com/milinda/samza/blob/rb34664/samza-sql-calcite/src/main/java/org/apache/samza/sql/planner/QueryPlanner.java#L128

On Fri, Nov 13, 2015 at 11:54 AM, Jacques Nadeau <[email protected]> wrote:

> The companion class to DrillSqlWorker is DefaultSqlHandler [1]. Drill
> actually does five or so phases of planning, moving back and forth between
> Hep and Volcano.
>
> [1]
>
> https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/DefaultSqlHandler.java
>
>
>
> On Fri, Nov 13, 2015 at 2:13 AM, Amogh Margoor <[email protected]> wrote:
>
> > Hi,
> > We want to use Volcanno planner and get back the optimized Logical
> RelNode.
> > Currently, we modified CalcitePrepareImpl.java
> > <
> >
> https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/prepare/CalcitePrepareImpl.java
> > >,
> > so that it returns us the optimized RelNode half way through, but it's
> > Enumberable. We were trying to find cleaner ways to do it through
> > Frameworks and stumbled upon this piece of code in Apache Drill:
> > DrillSqlWorker
> > <
> >
> https://github.com/apache/drill/blob/master/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/DrillSqlWorker.java
> > >.
> > Here Frameworks is used to get RelNode, which they pass to Hep planner.
> We
> > tried to do same with Volcanno Planner but it throws up during
> optimization
> > saying "Relational expression .. belongs to a different planner than is
> > currently being used". Any other way we can do it  or are we missing
> > something here ?
> >
> > Regards,
> > Amogh
> >
>



-- 
Milinda Pathirage

PhD Student | Research Assistant
School of Informatics and Computing | Data to Insight Center
Indiana University

twitter: milindalakmal
skype: milinda.pathirage
blog: http://milinda.pathirage.org

Reply via email to