You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by vl...@apache.org on 2018/09/25 15:21:51 UTC
calcite git commit: [CALCITE-2580] RexSimplify: coalesce(null > null,
true) produces wrong result filter expressions (pengzhiwei)
Repository: calcite
Updated Branches:
refs/heads/master b31da2246 -> a5d4a8b53
[CALCITE-2580] RexSimplify: coalesce(null > null, true) produces wrong result filter expressions (pengzhiwei)
fixes #865
Project: http://git-wip-us.apache.org/repos/asf/calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/a5d4a8b5
Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/a5d4a8b5
Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/a5d4a8b5
Branch: refs/heads/master
Commit: a5d4a8b53cebbf781f0c457bdccc576ec1a9d036
Parents: b31da22
Author: pengzhiwei <pe...@icloud.com>
Authored: Tue Sep 25 18:55:47 2018 +0800
Committer: Vladimir Sitnikov <si...@gmail.com>
Committed: Tue Sep 25 18:19:42 2018 +0300
----------------------------------------------------------------------
core/src/main/java/org/apache/calcite/rex/RexSimplify.java | 3 ++-
core/src/test/java/org/apache/calcite/test/RexProgramTest.java | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/calcite/blob/a5d4a8b5/core/src/main/java/org/apache/calcite/rex/RexSimplify.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rex/RexSimplify.java b/core/src/main/java/org/apache/calcite/rex/RexSimplify.java
index 5358f7f..02a1e51 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexSimplify.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexSimplify.java
@@ -577,8 +577,9 @@ public class RexSimplify {
private RexNode simplifyCoalesce(RexCall call) {
final Set<String> digests = new HashSet<>();
final List<RexNode> operands = new ArrayList<>();
+ final RexSimplify simplify = withUnknownAsFalse(false);
for (RexNode operand : call.getOperands()) {
- operand = simplify_(operand);
+ operand = simplify.simplify_(operand);
if (digests.add(operand.digest)) {
operands.add(operand);
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/a5d4a8b5/core/src/test/java/org/apache/calcite/test/RexProgramTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/RexProgramTest.java b/core/src/test/java/org/apache/calcite/test/RexProgramTest.java
index 4aa6a2c..6c1960a 100644
--- a/core/src/test/java/org/apache/calcite/test/RexProgramTest.java
+++ b/core/src/test/java/org/apache/calcite/test/RexProgramTest.java
@@ -1210,7 +1210,8 @@ public class RexProgramTest extends RexProgramBuilderBase {
checkSimplify(coalesce(iRef, literal1), "COALESCE(?0.i, 1)");
checkSimplify(coalesce(iRef, plus(iRef, hRef), literal1, hRef),
"COALESCE(?0.i, +(?0.i, ?0.h), 1)");
-
+ checkSimplify2(coalesce(gt(nullInt, nullInt), trueLiteral),
+ "COALESCE(null, true)", "COALESCE(null, true)");
// "(not x) is null" to "x is null"
checkSimplify(isNull(not(vBool())), "IS NULL(?0.bool0)");
checkSimplify(isNull(not(vBoolNotNull())), "false");