carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chenliang...@apache.org
Subject [08/50] [abbrv] incubator-carbondata git commit: [Bug] For fixing arithmetic expression filter issues in Filters. (#817)
Date Wed, 20 Jul 2016 10:13:36 GMT
[Bug] For fixing arithmetic expression filter issues in Filters. (#817)



Project: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/commit/e18c3058
Tree: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/tree/e18c3058
Diff: http://git-wip-us.apache.org/repos/asf/incubator-carbondata/diff/e18c3058

Branch: refs/heads/master
Commit: e18c3058ccf3db21f37b521c30df1f1fe823c0c0
Parents: f6488ca
Author: sujith71955 <sujithchacko.2010@gmail.com>
Authored: Fri Jul 15 12:28:38 2016 +0530
Committer: Vimal-Das <vimaldas.kammath@gmail.com>
Committed: Fri Jul 15 12:28:38 2016 +0530

----------------------------------------------------------------------
 .../carbondata/query/filters/FilterExpressionProcessor.java | 8 ++++----
 .../query/filters/measurefilter/util/FilterUtil.java        | 7 ++++---
 .../detailquery/HighCardinalityDataTypesTestCase.scala      | 9 +++++++--
 3 files changed, 15 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/e18c3058/core/src/main/java/org/carbondata/query/filters/FilterExpressionProcessor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/filters/FilterExpressionProcessor.java
b/core/src/main/java/org/carbondata/query/filters/FilterExpressionProcessor.java
index 889f728..3eef391 100644
--- a/core/src/main/java/org/carbondata/query/filters/FilterExpressionProcessor.java
+++ b/core/src/main/java/org/carbondata/query/filters/FilterExpressionProcessor.java
@@ -274,9 +274,9 @@ public class FilterExpressionProcessor implements FilterProcessor {
               .getCarbonColumn().hasEncoding(Encoding.DIRECT_DICTIONARY)) {
             if (FilterUtil.checkIfExpressionContainsColumn(currentCondExpression.getLeft())
                 && FilterUtil.checkIfExpressionContainsColumn(currentCondExpression.getRight())
|| (
-                FilterUtil.checkIfExpressionContainsUnknownExp(currentCondExpression.getRight())
+                FilterUtil.checkIfLeftExpressionRequireEvaluation(currentCondExpression.getRight())
                     || FilterUtil
-                    .checkIfExpressionContainsUnknownExp(currentCondExpression.getLeft())))
{
+                    .checkIfLeftExpressionRequireEvaluation(currentCondExpression.getLeft())))
{
               return new RowLevelFilterResolverImpl(expression, isExpressionResolve, true,
                   tableIdentifier);
             }
@@ -306,9 +306,9 @@ public class FilterExpressionProcessor implements FilterProcessor {
               .getCarbonColumn().hasEncoding(Encoding.DIRECT_DICTIONARY)) {
             if (FilterUtil.checkIfExpressionContainsColumn(currentCondExpression.getLeft())
                 && FilterUtil.checkIfExpressionContainsColumn(currentCondExpression.getRight())
|| (
-                FilterUtil.checkIfExpressionContainsUnknownExp(currentCondExpression.getRight())
+                FilterUtil.checkIfLeftExpressionRequireEvaluation(currentCondExpression.getRight())
                     || FilterUtil
-                    .checkIfExpressionContainsUnknownExp(currentCondExpression.getLeft())))
{
+                    .checkIfLeftExpressionRequireEvaluation(currentCondExpression.getLeft())))
{
               return new RowLevelFilterResolverImpl(expression, isExpressionResolve, false,
                   tableIdentifier);
             }

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/e18c3058/core/src/main/java/org/carbondata/query/filters/measurefilter/util/FilterUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/carbondata/query/filters/measurefilter/util/FilterUtil.java
b/core/src/main/java/org/carbondata/query/filters/measurefilter/util/FilterUtil.java
index 80e40a3..7ad22f4 100644
--- a/core/src/main/java/org/carbondata/query/filters/measurefilter/util/FilterUtil.java
+++ b/core/src/main/java/org/carbondata/query/filters/measurefilter/util/FilterUtil.java
@@ -222,12 +222,13 @@ public final class FilterUtil {
    *
    * @return
    */
-  public static boolean checkIfExpressionContainsUnknownExp(Expression expression) {
-    if (expression.getFilterExpressionType() == ExpressionType.UNKNOWN) {
+  public static boolean checkIfLeftExpressionRequireEvaluation(Expression expression) {
+    if (expression.getFilterExpressionType() == ExpressionType.UNKNOWN
+        || !(expression instanceof ColumnExpression)) {
       return true;
     }
     for (Expression child : expression.getChildren()) {
-      if (checkIfExpressionContainsUnknownExp(child)) {
+      if (checkIfLeftExpressionRequireEvaluation(child)) {
         return true;
       }
     }

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/e18c3058/integration/spark/src/test/scala/org/carbondata/spark/testsuite/detailquery/HighCardinalityDataTypesTestCase.scala
----------------------------------------------------------------------
diff --git a/integration/spark/src/test/scala/org/carbondata/spark/testsuite/detailquery/HighCardinalityDataTypesTestCase.scala
b/integration/spark/src/test/scala/org/carbondata/spark/testsuite/detailquery/HighCardinalityDataTypesTestCase.scala
index 65e125e..b22740e 100644
--- a/integration/spark/src/test/scala/org/carbondata/spark/testsuite/detailquery/HighCardinalityDataTypesTestCase.scala
+++ b/integration/spark/src/test/scala/org/carbondata/spark/testsuite/detailquery/HighCardinalityDataTypesTestCase.scala
@@ -26,7 +26,6 @@ import org.apache.spark.sql.Row
 import org.carbondata.core.constants.CarbonCommonConstants
 import org.carbondata.core.util.CarbonProperties
 
-
 /**
   * Test Class for verifying NO_DICTIONARY_COLUMN feature.
   *
@@ -157,7 +156,12 @@ class NO_DICTIONARY_COL_TestCase extends QueryTest with BeforeAndAfterAll
{
       Seq(Row(4), Row(6))
     )
   }
-
+test("filter with arithmetic expression") {
+    checkAnswer(
+      sql("select id from filtertestTable " + "where id+2 = 6"),
+      Seq(Row(4))
+    )
+  }
   test("Detail Query with NO_DICTIONARY_COLUMN with equals multiple filter Compare With HIVE
" +
     "RESULT"
   ) {
@@ -232,6 +236,7 @@ class NO_DICTIONARY_COL_TestCase extends QueryTest with BeforeAndAfterAll
{
       sql("select empno,empname,workgroupcategory from NO_DICTIONARY_CARBON_6 ")
     )
   }
+        
 
   override def afterAll {
     //sql("drop cube NO_DICTIONARY_HIVE_1")


Mime
View raw message