[
https://issues.apache.org/jira/browse/CALCITE-5370?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17633439#comment-17633439
]
Benchao Li commented on CALCITE-5370:
-------------------------------------
bq. Out of curiosity, if a rule can be applied both in HepPlanner and
VolcanoPlanner, will it behave differently? And if it doesn't, which one
(HepPlanner or VolcanoPlanner) should I choose? What's the underlying principle?
One of the main difference between {{HepPlanner}} and {{VolcanoPlanner}} is
that {{VolcanoPlanner}} could enforce trait requirement. The rules should not
be aware of what the planner they was applied, and should behave just the same
in different planner. It's the planner that will produce different result with
even the same rule sets.
When you need to change the traits of the {{RelNode}} tree, e.g. from NONE
Convetion to EnumerableConvention, you should use {{VolcanoPlanner}}. Another
case is when you want to produce a plan based on the cost, instead of just
heuristic optimizations. Otherwise, you can choose the {{HepPlanner}}.
> AGGREGATE_REMOVE will convert certain SQL statement into RelSubSet
> ------------------------------------------------------------------
>
> Key: CALCITE-5370
> URL: https://issues.apache.org/jira/browse/CALCITE-5370
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.32.0
> Reporter: alaneuler
> Priority: Major
>
> SQL:
> {code:java}
> SELECT name, sum(count_inner)
> FROM
> (SELECT name, COUNT(*) AS count_inner
> FROM pt_lsb
> GROUP BY name
> ORDER BY count_inner LIMIT 100)
> GROUP BY name {code}
> Table:
> {code:java}
> CREATE TABLE IF NOT EXISTS `pt_lsb` (name VARCHAR(20) NOT NULL) {code}
> After the `onMatch` method of rule AGGREGATE_REMOVE, it converts the RelNode
> into a RelSubset and this RelSubset cannot be converted into a SQL string:
> Error:
> {code:java}
> Exception in thread "main" java.lang.AssertionError: Need to implement
> org.apache.calcite.plan.volcano.RelSubset
> at
> org.apache.calcite.rel.rel2sql.RelToSqlConverter.visit(RelToSqlConverter.java:170)
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
> Method)
> at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
> at
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.base/java.lang.reflect.Method.invoke(Method.java:568)
> at org.apache.calcite.util.ReflectUtil$2.invoke(ReflectUtil.java:531)
> at
> org.apache.calcite.rel.rel2sql.RelToSqlConverter.dispatch(RelToSqlConverter.java:139)
> at
> org.apache.calcite.rel.rel2sql.RelToSqlConverter.visitInput(RelToSqlConverter.java:147)
> at
> org.apache.calcite.rel.rel2sql.SqlImplementor.visitInput(SqlImplementor.java:216)
> at
> org.apache.calcite.rel.rel2sql.SqlImplementor.visitInput(SqlImplementor.java:204)
> at
> org.apache.calcite.rel.rel2sql.SqlImplementor.visitRoot(SqlImplementor.java:180)
> at
> me.alaneuler.calcite.ng.demo.util.SqlUtils.toSqlString(SqlUtils.java:13)
> at
> me.alaneuler.calcite.ng.demo.util.SqlUtils.toSqlString(SqlUtils.java:17)
> at me.alaneuler.calcite.ng.demo.AggRemoveMain.main(AggRemoveMain.java:51)
> Suppressed: java.lang.Throwable: Error while converting RelNode to
> SqlNode:
> HepRelVertex(subset=[rel#17:RelSubset#0.NONE.[]]) at
> org.apache.calcite.util.Util.throwAsRuntime(Util.java:967)
> at
> org.apache.calcite.rel.rel2sql.SqlImplementor.visitRoot(SqlImplementor.java:182)
> ... 3 more {code}
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)