Hi,

I've been struggling to figure out how to do a very simple thing with
calcite. Hook it to a database, pass a query to a query planner and get
optimization rules applied to it.

I couldn't find any documentation that shows start to end how to enable
some rule and get a query optimized. What we've been able to do so far is
to get a logical plan from calcite doing somehting like this:

SqlNode sqlNode = planner.parse(query);
SqlNode validatedSqlNode = planner.validate(sqlNode);
RelRoot rel = planner.rel(validatedSqlNode);
RelNode project = rel.project();

We then create a HepPlanner and call findBestExp. I saw that Hive project
is doing something very similar here:
https://github.com/apache/hive/blob/198487557d17d53fa9216a3e814b7eb073da4781/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java#L1843

But is it required to use HepPlanner? I see that once I call
planner.rel(validatedSqlNode) that the resulting RelNode already has a
volcanoPlanner attached. How do I actually apply some optimization rules to
it? A fully working example would be appreciated and something that would
be very useful on the documentation pages.

Thanks a lot for any help with this.

Reply via email to