You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "jingzhang (JIRA)" <ji...@apache.org> on 2018/01/15 06:39:00 UTC
[jira] [Updated] (CALCITE-2134) AggregateJoinTransposeRule fails in
optimize phase based on CBO because of the bug in RelMdColumnUniqueness
[ https://issues.apache.org/jira/browse/CALCITE-2134?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
jingzhang updated CALCITE-2134:
-------------------------------
Attachment: 02-snippet.sql
> 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: jingzhang
> Assignee: Julian Hyde
> Priority: Major
> Attachments: 02-snippet.sql, 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
(v7.6.3#76005)