You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by ch...@apache.org on 2017/03/29 13:52:14 UTC

[1/2] incubator-carbondata git commit: Fixed issue 708 and added testcases for the same

Repository: incubator-carbondata
Updated Branches:
  refs/heads/master bd5114097 -> 3d5cf456d


Fixed issue 708 and added testcases for the same

Fixed styling issues


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

Branch: refs/heads/master
Commit: c5c6e65b7978c92f70036dda01bab6f01b3d9b96
Parents: bd51140
Author: Bhavya <bh...@knoldus.com>
Authored: Fri Mar 24 16:46:39 2017 +0530
Committer: chenliang613 <ch...@huawei.com>
Committed: Wed Mar 29 19:21:11 2017 +0530

----------------------------------------------------------------------
 .../src/test/resources/filter/betweenFilter.csv |  8 +++
 .../filterexpr/TestBetweenFilter.scala          | 73 ++++++++++++++++++++
 .../apache/carbondata/spark/CarbonFilters.scala | 11 ++-
 3 files changed, 90 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/c5c6e65b/integration/spark-common-test/src/test/resources/filter/betweenFilter.csv
----------------------------------------------------------------------
diff --git a/integration/spark-common-test/src/test/resources/filter/betweenFilter.csv b/integration/spark-common-test/src/test/resources/filter/betweenFilter.csv
new file mode 100644
index 0000000..b8d517a
--- /dev/null
+++ b/integration/spark-common-test/src/test/resources/filter/betweenFilter.csv
@@ -0,0 +1,8 @@
+id,name,orders
+1,Bhavya,10
+2,Sandeep,20
+3,Vijay,5
+4,Manish,6
+5,Kunal,10
+6,Divya,11
+7,India,12
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/c5c6e65b/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/filterexpr/TestBetweenFilter.scala
----------------------------------------------------------------------
diff --git a/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/filterexpr/TestBetweenFilter.scala b/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/filterexpr/TestBetweenFilter.scala
new file mode 100644
index 0000000..78447b3
--- /dev/null
+++ b/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/filterexpr/TestBetweenFilter.scala
@@ -0,0 +1,73 @@
+/*
+ * 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 org.apache.spark.sql.Row
+import org.apache.spark.sql.common.util.QueryTest
+import org.scalatest.BeforeAndAfterAll
+
+/**
+ * Test cases for testing columns having \N or \null values for non numeric columns
+ */
+class TestBetweenFilter extends QueryTest with BeforeAndAfterAll {
+
+  override def beforeAll {
+    sql("DROP TABLE IF EXISTS carbonTableBetween")
+
+    val csvFilePath = s"$resourcesPath/filter/betweenFilter.csv"
+    sql("""
+           CREATE TABLE IF NOT EXISTS carbonTableBetween
+           (id String, name String, orders int)
+           STORED BY 'carbondata' TBLPROPERTIES ('DICTIONARY_INCLUDE'='id')
+        """)
+    sql(s"""
+           LOAD DATA LOCAL INPATH '$csvFilePath' into table carbonTableBetween OPTIONS('BAD_RECORDS_ACTION'='FORCE')
+           """)
+  }
+
+
+  test("SELECT id FROM carbonTableBetween where id >= 1") {
+    checkAnswer(
+      sql("SELECT id FROM carbonTableBetween where id >= 1"),
+      Seq(Row("1"), Row("2"), Row("3"), Row("4"), Row("5"), Row("6"), Row("7")))
+  }
+
+  test("SELECT id FROM carbonTableBetween where id >= 1 and id < 5") {
+    checkAnswer(
+      sql("SELECT id FROM carbonTableBetween where id >= 1  and id < 5"),
+      Seq(Row("1"), Row("2"), Row("3"), Row("4")))
+  }
+
+  test("SELECT id FROM carbonTableBetween where id > 1 and id < 3") {
+    checkAnswer(
+      sql("SELECT id FROM carbonTableBetween where id > 1 and id < 3"),
+      Seq(Row("2")))
+  }
+
+  test("SELECT id FROM carbonTableBetween where id between 1 and 3") {
+    checkAnswer(
+      sql("SELECT id FROM carbonTableBetween where id between 1 and 3"),
+      Seq(Row("1"),Row("2"),Row("3")))
+  }
+
+
+
+  override def afterAll {
+    sql("drop table if exists carbonTableBetween")
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/c5c6e65b/integration/spark-common/src/main/scala/org/apache/carbondata/spark/CarbonFilters.scala
----------------------------------------------------------------------
diff --git a/integration/spark-common/src/main/scala/org/apache/carbondata/spark/CarbonFilters.scala b/integration/spark-common/src/main/scala/org/apache/carbondata/spark/CarbonFilters.scala
index 8063ccb..5698dab 100644
--- a/integration/spark-common/src/main/scala/org/apache/carbondata/spark/CarbonFilters.scala
+++ b/integration/spark-common/src/main/scala/org/apache/carbondata/spark/CarbonFilters.scala
@@ -111,8 +111,15 @@ object CarbonFilters {
     }
 
     def getCarbonLiteralExpression(name: String, value: Any): CarbonExpression = {
-      new CarbonLiteralExpression(value,
-        CarbonScalaUtil.convertSparkToCarbonDataType(dataTypeOf(name)))
+      val dataTypeOfAttribute = CarbonScalaUtil.convertSparkToCarbonDataType(dataTypeOf(name))
+      val dataType = if (Option(value).isDefined
+                         && dataTypeOfAttribute == DataType.STRING
+                         && value.isInstanceOf[Double]) {
+        DataType.DOUBLE
+      } else {
+        dataTypeOfAttribute
+      }
+      new CarbonLiteralExpression(value, dataType)
     }
 
     createFilter(predicate)


[2/2] incubator-carbondata git commit: [CARBONDATA-708] Fixed Between and Logical AND issue This closes #697

Posted by ch...@apache.org.
[CARBONDATA-708] Fixed Between and Logical AND issue This closes #697


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

Branch: refs/heads/master
Commit: 3d5cf456d4b4396c8d6c2f492b738183adaef729
Parents: bd51140 c5c6e65
Author: chenliang613 <ch...@huawei.com>
Authored: Wed Mar 29 19:22:02 2017 +0530
Committer: chenliang613 <ch...@huawei.com>
Committed: Wed Mar 29 19:22:02 2017 +0530

----------------------------------------------------------------------
 .../src/test/resources/filter/betweenFilter.csv |  8 +++
 .../filterexpr/TestBetweenFilter.scala          | 73 ++++++++++++++++++++
 .../apache/carbondata/spark/CarbonFilters.scala | 11 ++-
 3 files changed, 90 insertions(+), 2 deletions(-)
----------------------------------------------------------------------