Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
-
None
Description
If runs tpch 02 query(in attachment) or snippet of 02(in attachment), the following exception will be thrown in AggregateJoinTranspose Rule during optimized phase based on VolcanoPlanner.
java.lang.AssertionError at org.apache.calcite.sql.SqlSplittableAggFunction$SelfSplitter.topSplit(SqlSplittableAggFunction.java:209) at org.apache.calcite.rel.rules.AggregateJoinTransposeRule.onMatch(AggregateJoinTransposeRule.java:310) at org.apache.calcite.plan.volcano.VolcanoRuleCall.onMatch(VolcanoRuleCall.java:212) at org.apache.calcite.plan.volcano.VolcanoPlanner.findBestExp(VolcanoPlanner.java:650)
The failure is caused by the RelMdColumnUniqueness's estimation of RelSubset type RelNodes, which does not take Join into consideration. I don't figure out why only includes Aggregate, Filter, Values, TableScan, Project yet.
public Boolean areColumnsUnique(RelSubset rel, RelMetadataQuery mq, ImmutableBitSet columns, boolean ignoreNulls) { int nullCount = 0; for (RelNode rel2 : rel.getRels()) { if (rel2 instanceof Aggregate || rel2 instanceof Filter || rel2 instanceof Values || rel2 instanceof TableScan || simplyProjects(rel2, columns)) { try { final Boolean unique = mq.areColumnsUnique(rel2, columns, ignoreNulls); if (unique != null) { if (unique) { return true; } } else { ++nullCount; } } catch (CyclicMetadataException e) { // Ignore this relational expression; there will be non-cyclic ones // in this set. } } } return nullCount == 0 ? false : null; }