You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by hy...@apache.org on 2019/08/16 21:20:27 UTC
[calcite] branch master updated: [CALCITE-3249]
Substitution#getRexShuttle does not consider RexLiteral (Jin Xing)
This is an automated email from the ASF dual-hosted git repository.
hyuan 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 0a6f53c [CALCITE-3249] Substitution#getRexShuttle does not consider RexLiteral (Jin Xing)
0a6f53c is described below
commit 0a6f53cb828cd39d78d1423361921bf40636943a
Author: jinxing <ji...@gmail.com>
AuthorDate: Wed Aug 14 16:10:14 2019 +0800
[CALCITE-3249] Substitution#getRexShuttle does not consider RexLiteral (Jin Xing)
---
.../org/apache/calcite/plan/SubstitutionVisitor.java | 8 ++++++++
.../org/apache/calcite/test/MaterializationTest.java | 20 ++++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java b/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java
index b477fbc..5e85dc2 100644
--- a/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java
+++ b/core/src/main/java/org/apache/calcite/plan/SubstitutionVisitor.java
@@ -1421,6 +1421,14 @@ public class SubstitutionVisitor {
}
return super.visitCall(call);
}
+
+ @Override public RexNode visitLiteral(RexLiteral literal) {
+ final Integer integer = map.get(literal);
+ if (integer != null) {
+ return new RexInputRef(integer, literal.getType());
+ }
+ return super.visitLiteral(literal);
+ }
};
}
diff --git a/core/src/test/java/org/apache/calcite/test/MaterializationTest.java b/core/src/test/java/org/apache/calcite/test/MaterializationTest.java
index 994241a..76e09cc 100644
--- a/core/src/test/java/org/apache/calcite/test/MaterializationTest.java
+++ b/core/src/test/java/org/apache/calcite/test/MaterializationTest.java
@@ -550,6 +550,26 @@ public class MaterializationTest {
"select count(*) + 1 as c, \"deptno\" from \"emps\" group by \"deptno\"");
}
+ @Test public void testAggregate3() {
+ String deduplicated =
+ "(select \"empid\", \"deptno\", \"name\", \"salary\", \"commission\"\n"
+ + "from \"emps\"\n"
+ + "group by \"empid\", \"deptno\", \"name\", \"salary\", \"commission\")";
+ String mv =
+ "select \"deptno\", sum(\"salary\"), sum(\"commission\"), sum(\"k\")\n"
+ + "from\n"
+ + " (select \"deptno\", \"salary\", \"commission\", 100 as \"k\"\n"
+ + " from " + deduplicated + ")\n"
+ + "group by \"deptno\"";
+ String query =
+ "select \"deptno\", sum(\"salary\"), sum(\"k\")\n"
+ + "from\n"
+ + " (select \"deptno\", \"salary\", 100 as \"k\"\n"
+ + " from " + deduplicated + ")\n"
+ + "group by \"deptno\"";
+ checkMaterialize(mv, query);
+ }
+
/** Aggregation query at same level of aggregation as aggregation
* materialization with grouping sets. */
@Test public void testAggregateGroupSets1() {