You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by ya...@apache.org on 2021/09/28 02:07:18 UTC
[calcite] branch master updated: [CALCITE-4779] GroupByList
contains constant literal, materialized view recognition failed (xzh)
This is an automated email from the ASF dual-hosted git repository.
yanlin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/master by this push:
new 219e41e [CALCITE-4779] GroupByList contains constant literal, materialized view recognition failed (xzh)
219e41e is described below
commit 219e41eab20533f02d41238d1ebc617cc813b9a2
Author: xzh <95...@qq.com>
AuthorDate: Sun Sep 19 16:20:43 2021 +0800
[CALCITE-4779] GroupByList contains constant literal, materialized view recognition failed (xzh)
---
.../calcite/plan/RelOptMaterializations.java | 1 +
.../MaterializedViewSubstitutionVisitorTest.java | 28 ++++++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/core/src/main/java/org/apache/calcite/plan/RelOptMaterializations.java b/core/src/main/java/org/apache/calcite/plan/RelOptMaterializations.java
index f91f560..a75909c 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelOptMaterializations.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelOptMaterializations.java
@@ -215,6 +215,7 @@ public abstract class RelOptMaterializations {
.addRuleInstance(CoreRules.PROJECT_REMOVE)
.addRuleInstance(CoreRules.PROJECT_JOIN_TRANSPOSE)
.addRuleInstance(CoreRules.PROJECT_SET_OP_TRANSPOSE)
+ .addRuleInstance(CoreRules.AGGREGATE_PROJECT_PULL_UP_CONSTANTS)
.addRuleInstance(CoreRules.FILTER_TO_CALC)
.addRuleInstance(CoreRules.PROJECT_TO_CALC)
.addRuleInstance(CoreRules.FILTER_CALC_MERGE)
diff --git a/core/src/test/java/org/apache/calcite/test/MaterializedViewSubstitutionVisitorTest.java b/core/src/test/java/org/apache/calcite/test/MaterializedViewSubstitutionVisitorTest.java
index e284755..dede0a7 100644
--- a/core/src/test/java/org/apache/calcite/test/MaterializedViewSubstitutionVisitorTest.java
+++ b/core/src/test/java/org/apache/calcite/test/MaterializedViewSubstitutionVisitorTest.java
@@ -1691,6 +1691,33 @@ public class MaterializedViewSubstitutionVisitorTest extends AbstractMaterialize
+ "EnumerableTableScan(table=[[hr, MV0]])")).ok();
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-4779">[CALCITE-4779]
+ * GroupByList contains constant literal, materialized view recognition failed</a>. */
+ @Test void testGroupByListContainsConstantLiteral() {
+ // Aggregate operator grouping set contains a literal and count(distinct col) function.
+ final String mv1 = ""
+ + "select \"deptno\", \"empid\"\n"
+ + "from \"emps\"\n"
+ + "group by \"deptno\", \"empid\"";
+ final String query1 = ""
+ + "select 'a', \"deptno\", count(distinct \"empid\")\n"
+ + "from \"emps\"\n"
+ + "group by 'a', \"deptno\"";
+ sql(mv1, query1).ok();
+
+ // Aggregate operator grouping set contains a literal and sum(col) function.
+ final String mv2 = ""
+ + "select \"deptno\", \"empid\", sum(\"empid\")\n"
+ + "from \"emps\"\n"
+ + "group by \"deptno\", \"empid\"";
+ final String query2 = ""
+ + "select 'a', \"deptno\", sum(\"empid\")\n"
+ + "from \"emps\"\n"
+ + "group by 'a', \"deptno\"";
+ sql(mv2, query2).ok();
+ }
+
final JavaTypeFactoryImpl typeFactory =
new JavaTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
private final RexBuilder rexBuilder = new RexBuilder(typeFactory);
@@ -1719,6 +1746,7 @@ public class MaterializedViewSubstitutionVisitorTest extends AbstractMaterialize
.addRuleInstance(CoreRules.PROJECT_REMOVE)
.addRuleInstance(CoreRules.PROJECT_JOIN_TRANSPOSE)
.addRuleInstance(CoreRules.PROJECT_SET_OP_TRANSPOSE)
+ .addRuleInstance(CoreRules.AGGREGATE_PROJECT_PULL_UP_CONSTANTS)
.addRuleInstance(CoreRules.FILTER_TO_CALC)
.addRuleInstance(CoreRules.PROJECT_TO_CALC)
.addRuleInstance(CoreRules.FILTER_CALC_MERGE)