You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jh...@apache.org on 2014/11/26 00:39:37 UTC
incubator-calcite git commit: [CALCITE-403] Enumerable gives
NullPointerException with NOT on nullable expression
Repository: incubator-calcite
Updated Branches:
refs/heads/master 539253562 -> de0bfaade
[CALCITE-403] Enumerable gives NullPointerException with NOT on nullable expression
Project: http://git-wip-us.apache.org/repos/asf/incubator-calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/de0bfaad
Tree: http://git-wip-us.apache.org/repos/asf/incubator-calcite/tree/de0bfaad
Diff: http://git-wip-us.apache.org/repos/asf/incubator-calcite/diff/de0bfaad
Branch: refs/heads/master
Commit: de0bfaade674ec325c5b6a5458f2da8ac6fcd3de
Parents: 5392535
Author: Julian Hyde <jh...@apache.org>
Authored: Tue Nov 25 14:53:04 2014 -0800
Committer: Julian Hyde <jh...@apache.org>
Committed: Tue Nov 25 14:53:21 2014 -0800
----------------------------------------------------------------------
.../calcite/adapter/enumerable/RexImpTable.java | 12 ++++++++++++
.../java/org/apache/calcite/test/JdbcTest.java | 18 +++++++++++++-----
2 files changed, 25 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/de0bfaad/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java b/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
index 9b129e5..b3166ec 100644
--- a/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
+++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
@@ -756,6 +756,18 @@ public class RexImpTable {
}
list.add(implementCall(translator, call, implementor, nullAs));
return Expressions.foldAnd(list);
+ case TRUE:
+ // v0 == null || v1 == null || f(v0, v1)
+ for (Ord<RexNode> operand : Ord.zip(call.getOperands())) {
+ if (translator.isNullable(operand.e)) {
+ list.add(
+ translator.translate(
+ operand.e, NullAs.IS_NULL));
+ translator = translator.setNullable(operand.e, false);
+ }
+ }
+ list.add(implementCall(translator, call, implementor, nullAs));
+ return Expressions.foldOr(list);
case NOT_POSSIBLE:
// Need to transmit to the implementor the fact that call cannot
// return null. In particular, it should return a primitive (e.g.
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/de0bfaad/core/src/test/java/org/apache/calcite/test/JdbcTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/JdbcTest.java b/core/src/test/java/org/apache/calcite/test/JdbcTest.java
index d5f2623..424bbe0 100644
--- a/core/src/test/java/org/apache/calcite/test/JdbcTest.java
+++ b/core/src/test/java/org/apache/calcite/test/JdbcTest.java
@@ -2977,23 +2977,31 @@ public class JdbcTest {
/** Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-403">CALCITE-403</a>,
- * "Enumerable gives NullPointerException with HAVING on nullable
+ * "Enumerable gives NullPointerException with NOT on nullable
* expression". */
- @Ignore("CALCITE-403")
@Test public void testHavingNot() throws IOException {
withFoodMartQuery(6597).runs();
}
/** Minimal case of {@link #testHavingNot()}. */
- @Ignore("CALCITE-403")
@Test public void testHavingNot2() throws IOException {
CalciteAssert.that()
.with(CalciteAssert.Config.FOODMART_CLONE)
.query("select 1\n"
+ "from \"store\"\n"
+ "group by \"store\".\"store_street_address\"\n"
- + "having NOT (sum(\"store\".\"grocery_sqft\") < 10000)")
- .returnsCount(0);
+ + "having NOT (sum(\"store\".\"grocery_sqft\") < 20000)")
+ .returnsCount(10);
+ }
+
+ @Test public void testWhereNot() throws IOException {
+ CalciteAssert.that()
+ .with(CalciteAssert.Config.FOODMART_CLONE)
+ .query("select 1\n"
+ + "from \"store\"\n"
+ + "where NOT (\"store\".\"grocery_sqft\" < 22000)\n"
+ + "group by \"store\".\"store_street_address\"\n")
+ .returnsCount(8);
}
/** Query that reads no columns from either underlying table. */