[
https://issues.apache.org/jira/browse/CALCITE-2134?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Drew Foulks updated CALCITE-2134:
---------------------------------
Reporter: Jing Zhang (was: Jing Zhang)
> AggregateJoinTransposeRule fails in optimize phase based on CBO because of
> the bug in RelMdColumnUniqueness
> -----------------------------------------------------------------------------------------------------------
>
> Key: CALCITE-2134
> URL: https://issues.apache.org/jira/browse/CALCITE-2134
> Project: Calcite
> Issue Type: Bug
> Reporter: Jing Zhang
> Priority: Major
> Attachments: 02-snippet.sql, 02.sql
>
>
> 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.
> {code}
> 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)
> {code}
> 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.
> {code}
> 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;
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)