You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by da...@apache.org on 2020/01/08 06:08:59 UTC
[calcite] branch master updated: Following CALCITE-3531,
make CURRENT_TIMESTAMP be recognized as constant in planner rules
This is an automated email from the ASF dual-hosted git repository.
danny0405 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 5cbe435 Following CALCITE-3531, make CURRENT_TIMESTAMP be recognized as constant in planner rules
5cbe435 is described below
commit 5cbe435eea5ec0ba8cbc7ddf8c2808936aea476c
Author: yuzhao.cyz <yu...@gmail.com>
AuthorDate: Wed Jan 8 12:18:01 2020 +0800
Following CALCITE-3531, make CURRENT_TIMESTAMP be recognized as constant in planner rules
---
core/src/main/java/org/apache/calcite/rex/RexUtil.java | 9 +++------
core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java | 2 +-
.../test/resources/org/apache/calcite/test/RelOptRulesTest.xml | 9 +++++----
3 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/core/src/main/java/org/apache/calcite/rex/RexUtil.java b/core/src/main/java/org/apache/calcite/rex/RexUtil.java
index bd9627e..27b2b22 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexUtil.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexUtil.java
@@ -517,12 +517,9 @@ public class RexUtil {
public Boolean visitCall(RexCall call) {
// Constant if operator meets the following conditions:
- // 1. It is non-dynamic, e.g. it is safe to
- // cache query plans referencing this operator;
- // 2. It is deterministic;
- // 3. All its operands are constant.
- return !call.getOperator().isDynamicFunction()
- && call.getOperator().isDeterministic()
+ // 1. It is deterministic;
+ // 2. All its operands are constant.
+ return call.getOperator().isDeterministic()
&& RexVisitorImpl.visitArrayAnd(this, call.getOperands());
}
diff --git a/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java b/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
index d82d3eb..13400f8 100644
--- a/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
+++ b/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
@@ -5316,7 +5316,7 @@ public class RelOptRulesTest extends RelOptTestBase {
+ "group by sal, hiredate\n"
+ "having count(*) > 3";
sql(sql).withRule(AggregateProjectPullUpConstantsRule.INSTANCE2)
- .checkUnchanged();
+ .check();
}
@Test public void testReduceExpressionsNot() {
diff --git a/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml b/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml
index 537a2d8..502fe7f 100644
--- a/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml
+++ b/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml
@@ -10674,10 +10674,11 @@ LogicalProject(HIREDATE=[$1])
<![CDATA[
LogicalProject(HIREDATE=[$1])
LogicalFilter(condition=[>($2, 3)])
- LogicalAggregate(group=[{0, 1}], agg#0=[COUNT()])
- LogicalProject(SAL=[$5], HIREDATE=[$4])
- LogicalFilter(condition=[AND(IS NULL($5), =($4, CURRENT_TIMESTAMP))])
- LogicalTableScan(table=[[CATALOG, SALES, EMP]])
+ LogicalProject(SAL=[$0], HIREDATE=[CURRENT_TIMESTAMP], $f2=[$1])
+ LogicalAggregate(group=[{0}], agg#0=[COUNT()])
+ LogicalProject(SAL=[$5], HIREDATE=[$4])
+ LogicalFilter(condition=[AND(IS NULL($5), =($4, CURRENT_TIMESTAMP))])
+ LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>