Which planner you use is generally going to depend on your goal in using
the optimizer. HepPlanner applies a given list of optimization rules until
none of those rules are applicable. VolcanoPlanner tries to estimate the
cost of executing a query and explores applying different rules in an
attempt to minimize this cost.

--
Michael Mior
mm...@apache.org



Le mer. 29 août 2018 à 15:21, Z. S. <zilvinas.sal...@gmail.com> a écrit :

> 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