You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by gv...@apache.org on 2017/05/18 09:06:51 UTC
[1/2] carbondata git commit: updated null check for right expression
in not in expression
Repository: carbondata
Updated Branches:
refs/heads/master 08badd025 -> 75afd0680
updated null check for right expression in not in expression
Project: http://git-wip-us.apache.org/repos/asf/carbondata/repo
Commit: http://git-wip-us.apache.org/repos/asf/carbondata/commit/749dd451
Tree: http://git-wip-us.apache.org/repos/asf/carbondata/tree/749dd451
Diff: http://git-wip-us.apache.org/repos/asf/carbondata/diff/749dd451
Branch: refs/heads/master
Commit: 749dd451914644212adad0393e51725b8605ab1d
Parents: 08badd0
Author: kunal642 <ku...@knoldus.in>
Authored: Thu May 18 13:48:34 2017 +0530
Committer: Venkata Ramana Gollamudi <g....@gmail.com>
Committed: Thu May 18 14:33:52 2017 +0530
----------------------------------------------------------------------
.../expression/conditional/NotInExpression.java | 22 ++++++++++----------
.../ExpressionWithNullTestCase.scala | 2 ++
2 files changed, 13 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/carbondata/blob/749dd451/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/NotInExpression.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/NotInExpression.java b/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/NotInExpression.java
index 2552f96..67e3a50 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/NotInExpression.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/expression/conditional/NotInExpression.java
@@ -42,6 +42,17 @@ public class NotInExpression extends BinaryConditionalExpression {
if (setOfExprResult == null) {
ExpressionResult val = null;
ExpressionResult rightRsult = right.evaluate(value);
+ // Both left and right result need to be checked for null because NotInExpression is basically
+ // an And Operation on the list of predicates that are provided.
+ // Example: x in (1,2,null) would be converted to x=1 AND x=2 AND x=null.
+ // If any of the predicates is null then the result is unknown for all the predicates thus
+ // we will return false for each of them.
+ for (ExpressionResult expressionResult: rightRsult.getList()) {
+ if (expressionResult.isNull() || leftRsult.isNull()) {
+ leftRsult.set(DataType.BOOLEAN, false);
+ return leftRsult;
+ }
+ }
setOfExprResult = new HashSet<ExpressionResult>(10);
for (ExpressionResult exprResVal : rightRsult.getList()) {
if (exprResVal.getDataType().getPrecedenceOrder() < leftRsult.getDataType()
@@ -80,17 +91,6 @@ public class NotInExpression extends BinaryConditionalExpression {
setOfExprResult.add(val);
}
}
- // Both left and right results need to be checked for null because NotInExpression is basically
- // an And Operation on the list of predicates that are provided.
- // Example: x in (1,2,null) would be converted to x=1 AND x=2 AND x=null.
- // If any of the predicates is null then the result is unknown for all the predicates thus
- // we will return false for each of them.
- for (ExpressionResult expressionResult: setOfExprResult) {
- if (expressionResult.isNull() || leftRsult.isNull()) {
- leftRsult.set(DataType.BOOLEAN, false);
- return leftRsult;
- }
- }
leftRsult.set(DataType.BOOLEAN, !setOfExprResult.contains(leftRsult));
return leftRsult;
}
http://git-wip-us.apache.org/repos/asf/carbondata/blob/749dd451/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/detailquery/ExpressionWithNullTestCase.scala
----------------------------------------------------------------------
diff --git a/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/detailquery/ExpressionWithNullTestCase.scala b/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/detailquery/ExpressionWithNullTestCase.scala
index a421c7e..cbc2750 100644
--- a/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/detailquery/ExpressionWithNullTestCase.scala
+++ b/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/detailquery/ExpressionWithNullTestCase.scala
@@ -38,6 +38,7 @@ class ExpressionWithNullTestCase extends QueryTest with BeforeAndAfterAll {
}
test("test to check in expression with null values") {
+ checkAnswer(sql("select * from expression_test where id in (1,2,'', NULL, ' ')"), sql("select * from expression_test_hive where id in (1,2,' ', NULL, ' ')"))
checkAnswer(sql("select * from expression_test where id in (1,2,'')"), sql("select * from expression_test_hive where id in (1,2,'')"))
checkAnswer(sql("select * from expression_test where id in ('')"), sql("select * from expression_test_hive where id in ('')"))
checkAnswer(sql("select * from expression_test where number in (null)"), sql("select * from expression_test_hive where number in (null)"))
@@ -54,6 +55,7 @@ class ExpressionWithNullTestCase extends QueryTest with BeforeAndAfterAll {
}
test("test to check not in expression with null values") {
+ checkAnswer(sql("select * from expression_test where id not in (1,2,'', NULL, ' ')"), sql("select * from expression_test_hive where id not in (1,2,' ', NULL, ' ')"))
checkAnswer(sql("select * from expression_test where id not in (1,2,'')"), sql("select * from expression_test_hive where id not in (1,2,'')"))
checkAnswer(sql("select * from expression_test where id not in ('')"), sql("select * from expression_test_hive where id not in ('')"))
checkAnswer(sql("select * from expression_test where number not in (null)"), sql("select * from expression_test_hive where number not in (null)"))
[2/2] carbondata git commit: [CARBONDATA-1064] Updated null check for
right expression in not in expression. This closes #925
Posted by gv...@apache.org.
[CARBONDATA-1064] Updated null check for right expression in not in expression. This closes #925
Project: http://git-wip-us.apache.org/repos/asf/carbondata/repo
Commit: http://git-wip-us.apache.org/repos/asf/carbondata/commit/75afd068
Tree: http://git-wip-us.apache.org/repos/asf/carbondata/tree/75afd068
Diff: http://git-wip-us.apache.org/repos/asf/carbondata/diff/75afd068
Branch: refs/heads/master
Commit: 75afd068079ebbe944724c4dc6befc14790f38bb
Parents: 08badd0 749dd45
Author: Venkata Ramana Gollamudi <g....@gmail.com>
Authored: Thu May 18 14:36:44 2017 +0530
Committer: Venkata Ramana Gollamudi <g....@gmail.com>
Committed: Thu May 18 14:36:44 2017 +0530
----------------------------------------------------------------------
.../expression/conditional/NotInExpression.java | 22 ++++++++++----------
.../ExpressionWithNullTestCase.scala | 2 ++
2 files changed, 13 insertions(+), 11 deletions(-)
----------------------------------------------------------------------