carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ravipes...@apache.org
Subject [1/2] incubator-carbondata git commit: [CARBONDATA-195] Select query with AND filter failing for empty '' operand value of numeric column
Date Thu, 01 Sep 2016 07:15:45 GMT
Repository: incubator-carbondata
Updated Branches:
  refs/heads/master eb12b8517 -> faba524b2


[CARBONDATA-195] Select query with AND filter failing for empty '' operand value of numeric
column


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

Branch: refs/heads/master
Commit: fc57aa6f50dd201e95a059b969df1a362f938bcd
Parents: eb12b85
Author: mohammadshahidkhan <mohdshahidkhan1987@gmail.com>
Authored: Wed Aug 31 20:18:11 2016 +0530
Committer: mohammadshahidkhan <mohdshahidkhan1987@gmail.com>
Committed: Thu Sep 1 12:04:16 2016 +0530

----------------------------------------------------------------------
 .../scan/filter/FilterExpressionProcessor.java  | 26 +++---
 .../TestAndEqualFilterEmptyOperandValue.scala   | 89 ++++++++++++++++++++
 2 files changed, 101 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/fc57aa6f/core/src/main/java/org/apache/carbondata/scan/filter/FilterExpressionProcessor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/scan/filter/FilterExpressionProcessor.java
b/core/src/main/java/org/apache/carbondata/scan/filter/FilterExpressionProcessor.java
index b17dd3e..9d996a0 100644
--- a/core/src/main/java/org/apache/carbondata/scan/filter/FilterExpressionProcessor.java
+++ b/core/src/main/java/org/apache/carbondata/scan/filter/FilterExpressionProcessor.java
@@ -328,22 +328,20 @@ public class FilterExpressionProcessor implements FilterProcessor {
         }
         break;
       default:
-        condExpression = (ConditionalExpression) expression;
-        if (condExpression.isSingleDimension()
-            && condExpression.getColumnList().get(0).getCarbonColumn().getDataType()
-            != DataType.ARRAY
-            && condExpression.getColumnList().get(0).getCarbonColumn().getDataType()
-            != DataType.STRUCT) {
+        if(expression instanceof ConditionalExpression) {
           condExpression = (ConditionalExpression) expression;
-          if (condExpression.getColumnList().get(0).getCarbonColumn()
-              .hasEncoding(Encoding.DICTIONARY) && !condExpression.getColumnList().get(0)
-              .getCarbonColumn().hasEncoding(Encoding.DIRECT_DICTIONARY)) {
-            return new ConditionalFilterResolverImpl(expression, true, true);
-          } else {
-            return new RowLevelFilterResolverImpl(expression, false, false, tableIdentifier);
+          if (condExpression.isSingleDimension()
+                  && condExpression.getColumnList().get(0).getCarbonColumn().getDataType()
+                  != DataType.ARRAY
+                  && condExpression.getColumnList().get(0).getCarbonColumn().getDataType()
+                  != DataType.STRUCT) {
+            condExpression = (ConditionalExpression) expression;
+            if (condExpression.getColumnList().get(0).getCarbonColumn()
+                    .hasEncoding(Encoding.DICTIONARY) && !condExpression.getColumnList().get(0)
+                    .getCarbonColumn().hasEncoding(Encoding.DIRECT_DICTIONARY)) {
+              return new ConditionalFilterResolverImpl(expression, true, true);
+            }
           }
-        } else {
-          return new RowLevelFilterResolverImpl(expression, false, false, tableIdentifier);
         }
     }
     return new RowLevelFilterResolverImpl(expression, false, false, tableIdentifier);

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/fc57aa6f/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/filterexpr/TestAndEqualFilterEmptyOperandValue.scala
----------------------------------------------------------------------
diff --git a/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/filterexpr/TestAndEqualFilterEmptyOperandValue.scala
b/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/filterexpr/TestAndEqualFilterEmptyOperandValue.scala
new file mode 100644
index 0000000..2da2b7d
--- /dev/null
+++ b/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/filterexpr/TestAndEqualFilterEmptyOperandValue.scala
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.carbondata.spark.testsuite.filterexpr
+
+import java.io.File
+
+import org.apache.spark.sql.common.util.CarbonHiveContext._
+import org.apache.spark.sql.common.util.QueryTest
+import org.scalatest.BeforeAndAfterAll
+
+import org.apache.carbondata.core.constants.CarbonCommonConstants
+import org.apache.carbondata.core.util.CarbonProperties
+
+/**
+ * Test cases for testing columns having \N or \null values for non numeric columns
+ */
+class TestAndEqualFilterEmptyOperandValue extends QueryTest with BeforeAndAfterAll {
+
+  override def beforeAll {
+    sql("drop table if exists carbonTable")
+    sql("drop table if exists hiveTable")
+    CarbonProperties.getInstance()
+      .addProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT,
+        CarbonCommonConstants.CARBON_TIMESTAMP_DEFAULT_FORMAT
+      )
+    val currentDirectory = new File(this.getClass.getResource("/").getPath + "/../../")
+      .getCanonicalPath
+    val csvFilePath = currentDirectory + "/src/test/resources/filter/datagrtlrt.csv"
+    sql(
+      "CREATE TABLE IF NOT EXISTS carbonTable(date Timestamp, country String, salary Int)
STORED " +
+      "BY " +
+      "'carbondata'"
+    )
+    sql(
+      "create table if not exists hiveTable(date Timestamp, country String, salary Int)row
format" +
+      " delimited fields " +
+      "terminated by ','"
+    )
+    sql(
+      "LOAD DATA LOCAL INPATH '" + csvFilePath + "' into table carbonTable OPTIONS " +
+      "('FILEHEADER'='date,country,salary')"
+    )
+    sql(
+      "LOAD DATA local inpath '" + csvFilePath + "' INTO table hiveTable"
+    )
+  }
+
+  test("select * from carbonTable where country='' and salary='')") {
+    sql("select * from carbonTable where country='' and salary=''").show()
+    sql("select * from hiveTable where country='' and salary=''").show()
+    checkAnswer(
+      sql("select * from carbonTable where country='' and salary=''"),
+      sql("select * from hiveTable where country='' and salary=''")
+    )
+  }
+
+  test("select * from carbonTable where date='' and salary='')") {
+    sql("select * from carbonTable where date='' and salary=''").show()
+    sql("select * from hiveTable where date='' and salary=''").show()
+    checkAnswer(
+      sql("select * from carbonTable where date='' and salary=''"),
+      sql("select * from hiveTable where date='' and salary=''")
+    )
+  }
+
+  override def afterAll {
+    sql("drop table if exists carbonTable")
+    sql("drop table if exists hiveTable")
+    CarbonProperties.getInstance()
+      .addProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT, "dd-MM-yyyy")
+  }
+}


Mime
View raw message