carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chenliang...@apache.org
Subject carbondata git commit: [CARBONDATA-1312] fix list partition compare issue
Date Fri, 21 Jul 2017 08:33:18 GMT
Repository: carbondata
Updated Branches:
  refs/heads/master df22368d9 -> c7aba5e5d


[CARBONDATA-1312] fix list partition compare issue

This closes #1183


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

Branch: refs/heads/master
Commit: c7aba5e5d831440c438e6448b00bbd98e7a5acd6
Parents: df22368
Author: lionelcao <whucaolu@gmail.com>
Authored: Tue Jul 18 23:45:23 2017 +0800
Committer: chenliang613 <chenliang613@apache.org>
Committed: Fri Jul 21 16:33:00 2017 +0800

----------------------------------------------------------------------
 .../filter/partition/PartitionFilterUtil.java   |  34 +++-
 .../scan/filter/partition/RangeFilterImpl.java  |   3 +
 .../partition/TestQueryForPartitionTable.scala  | 197 ++++++++++++++++---
 3 files changed, 194 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/c7aba5e5/core/src/main/java/org/apache/carbondata/core/scan/filter/partition/PartitionFilterUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/filter/partition/PartitionFilterUtil.java
b/core/src/main/java/org/apache/carbondata/core/scan/filter/partition/PartitionFilterUtil.java
index efb8bdb..d040c1b 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/filter/partition/PartitionFilterUtil.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/filter/partition/PartitionFilterUtil.java
@@ -26,6 +26,7 @@ import org.apache.carbondata.core.metadata.schema.PartitionInfo;
 import org.apache.carbondata.core.scan.partition.ListPartitioner;
 import org.apache.carbondata.core.scan.partition.PartitionUtil;
 import org.apache.carbondata.core.scan.partition.RangePartitioner;
+import org.apache.carbondata.core.util.ByteUtil;
 import org.apache.carbondata.core.util.comparator.Comparator;
 import org.apache.carbondata.core.util.comparator.SerializableComparator;
 
@@ -44,7 +45,7 @@ public class PartitionFilterUtil {
       ListPartitioner partitioner, Object filterValue,  boolean isGreaterThan, boolean isEqualTo,
       DateFormat timestampFormatter, DateFormat dateFormatter) {
 
-    List<List<String>> values = partitionInfo.getListInfo();
+    List<List<String>> listInfo = partitionInfo.getListInfo();
     DataType partitionColumnDataType = partitionInfo.getColumnSchemaList().get(0).getDataType();
 
     SerializableComparator comparator =
@@ -53,16 +54,18 @@ public class PartitionFilterUtil {
     BitSet partitionMap = PartitionUtil.generateBitSetBySize(partitioner.numPartitions(),
false);
     // add default partition
     partitionMap.set(0);
-
-    int partitions = values.size();
+    int partitions = listInfo.size();
     if (isGreaterThan) {
       if (isEqualTo) {
         // GreaterThanEqualTo(>=)
         outer1:
         for (int i = 0; i < partitions; i++) {
-          for (String value : values.get(i)) {
+          for (String value : listInfo.get(i)) {
             Object listValue = PartitionUtil.getDataBasedOnDataType(value, partitionColumnDataType,
                 timestampFormatter, dateFormatter);
+            if (listValue instanceof String) {
+              listValue = ByteUtil.toBytes((String)listValue);
+            }
             if (comparator.compare(listValue, filterValue) >= 0) {
               partitionMap.set(i + 1);
               continue outer1;
@@ -73,9 +76,12 @@ public class PartitionFilterUtil {
         // GreaterThan(>)
         outer2:
         for (int i = 0; i < partitions; i++) {
-          for (String value : values.get(i)) {
+          for (String value : listInfo.get(i)) {
             Object listValue = PartitionUtil.getDataBasedOnDataType(value, partitionColumnDataType,
                 timestampFormatter, dateFormatter);
+            if (listValue instanceof String) {
+              listValue = ByteUtil.toBytes((String)listValue);
+            }
             if (comparator.compare(listValue, filterValue) > 0) {
               partitionMap.set(i + 1);
               continue outer2;
@@ -88,9 +94,12 @@ public class PartitionFilterUtil {
         // LessThanEqualTo(<=)
         outer3:
         for (int i = 0; i < partitions; i++) {
-          for (String value : values.get(i)) {
+          for (String value : listInfo.get(i)) {
             Object listValue = PartitionUtil.getDataBasedOnDataType(value, partitionColumnDataType,
                 timestampFormatter, dateFormatter);
+            if (listValue instanceof String) {
+              listValue = ByteUtil.toBytes((String)listValue);
+            }
             if (comparator.compare(listValue, filterValue) <= 0) {
               partitionMap.set(i + 1);
               continue outer3;
@@ -101,9 +110,12 @@ public class PartitionFilterUtil {
         // LessThanEqualTo(<)
         outer4:
         for (int i = 0; i < partitions; i++) {
-          for (String value : values.get(i)) {
+          for (String value : listInfo.get(i)) {
             Object listValue = PartitionUtil.getDataBasedOnDataType(value, partitionColumnDataType,
                 timestampFormatter, dateFormatter);
+            if (listValue instanceof String) {
+              listValue = ByteUtil.toBytes((String)listValue);
+            }
             if (comparator.compare(listValue, filterValue) < 0) {
               partitionMap.set(i + 1);
               continue outer4;
@@ -143,8 +155,12 @@ public class PartitionFilterUtil {
     int partitionIndex = 0;
     // find the partition of filter value
     for (; partitionIndex < numPartitions; partitionIndex++) {
-      result = comparator.compare(filterValue, PartitionUtil.getDataBasedOnDataType(
-          values.get(partitionIndex), partitionColumnDataType, timestampFormatter, dateFormatter));
+      Object value = PartitionUtil.getDataBasedOnDataType(
+          values.get(partitionIndex), partitionColumnDataType, timestampFormatter, dateFormatter);
+      if (value instanceof String) {
+        value = ByteUtil.toBytes((String)value);
+      }
+      result = comparator.compare(filterValue, value);
       if (result <= 0) {
         break;
       }

http://git-wip-us.apache.org/repos/asf/carbondata/blob/c7aba5e5/core/src/main/java/org/apache/carbondata/core/scan/filter/partition/RangeFilterImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/carbondata/core/scan/filter/partition/RangeFilterImpl.java
b/core/src/main/java/org/apache/carbondata/core/scan/filter/partition/RangeFilterImpl.java
index 0124d2b..6ed4cbc 100644
--- a/core/src/main/java/org/apache/carbondata/core/scan/filter/partition/RangeFilterImpl.java
+++ b/core/src/main/java/org/apache/carbondata/core/scan/filter/partition/RangeFilterImpl.java
@@ -63,6 +63,9 @@ public class RangeFilterImpl implements PartitionFilterIntf {
         Object filterValueOfList = PartitionUtil.getDataBasedOnDataTypeForFilter(
             literal.getLiteralExpValue().toString(),
             partitionInfo.getColumnSchemaList().get(0).getDataType());
+        if (filterValueOfList instanceof String) {
+          filterValueOfList = ByteUtil.toBytes((String)filterValueOfList);
+        }
         return PartitionFilterUtil.getPartitionMapForRangeFilter(partitionInfo,
             (ListPartitioner) partitioner, filterValueOfList, isGreaterThan, isEqualTo,
             timestampFormatter, dateFormatter);

http://git-wip-us.apache.org/repos/asf/carbondata/blob/c7aba5e5/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/partition/TestQueryForPartitionTable.scala
----------------------------------------------------------------------
diff --git a/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/partition/TestQueryForPartitionTable.scala
b/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/partition/TestQueryForPartitionTable.scala
index 77bde07..e02c6bf 100644
--- a/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/partition/TestQueryForPartitionTable.scala
+++ b/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/partition/TestQueryForPartitionTable.scala
@@ -39,11 +39,6 @@ class TestQueryForPartitionTable  extends QueryTest with BeforeAndAfterAll
{
         | STORED BY 'org.apache.carbondata.format'
       """.stripMargin)
 
-    sql(s"""LOAD DATA local inpath '$resourcesPath/data.csv' INTO TABLE originTable OPTIONS('DELIMITER'=
',', 'QUOTECHAR'= '"')""")
-
-  }
-
-  test("detail query on partition table: hash table") {
     sql(
       """
         | CREATE TABLE hashTable (empname String, designation String, doj Timestamp,
@@ -54,18 +49,7 @@ class TestQueryForPartitionTable  extends QueryTest with BeforeAndAfterAll
{
         | STORED BY 'org.apache.carbondata.format'
         | TBLPROPERTIES('PARTITION_TYPE'='HASH','NUM_PARTITIONS'='3')
       """.stripMargin)
-    sql(s"""LOAD DATA local inpath '$resourcesPath/data.csv' INTO TABLE hashTable OPTIONS('DELIMITER'=
',', 'QUOTECHAR'= '"')""")
 
-    // EqualTo
-    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from hashTable where empno = 13"),
-      sql("select  empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empno = 13"))
-    // In
-    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from hashTable where empno in (11, 13)"),
-      sql("select  empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empno in (11, 13)"))
-    sql("drop table hashTable")
-  }
-
-  test("detail query on partition table: range partition") {
     sql(
       """
         | CREATE TABLE rangeTable (empno int, empname String, designation String,
@@ -77,8 +61,88 @@ class TestQueryForPartitionTable  extends QueryTest with BeforeAndAfterAll
{
         | TBLPROPERTIES('PARTITION_TYPE'='RANGE',
         |  'RANGE_INFO'='01-01-2010, 01-01-2015, 01-04-2015, 01-07-2015')
       """.stripMargin)
+
+    sql(
+      """
+        | CREATE TABLE rangeTableOnString (empno int, designation String,
+        | doj Timestamp, workgroupcategory int, workgroupcategoryname String, deptno int,
+        | deptname String, projectcode int, projectjoindate Timestamp, projectenddate Timestamp,
+        | attendance int, utilization int,salary int)
+        | PARTITIONED BY (empname String)
+        | STORED BY 'org.apache.carbondata.format'
+        | TBLPROPERTIES('PARTITION_TYPE'='RANGE',
+        |  'RANGE_INFO'='Ben, Jack, Sam, Tom')
+      """.stripMargin)
+
+    sql(
+      """
+        | CREATE TABLE rangeTableOnStringNo (empno int, designation String,
+        | doj Timestamp, workgroupcategory int, workgroupcategoryname String, deptno int,
+        | deptname String, projectcode int, projectjoindate Timestamp, projectenddate Timestamp,
+        | attendance int, utilization int,salary int)
+        | PARTITIONED BY (empname String)
+        | STORED BY 'org.apache.carbondata.format'
+        | TBLPROPERTIES('PARTITION_TYPE'='RANGE',
+        |  'RANGE_INFO'='Ben, Jack, Sam, Tom', 'DICTIONARY_EXCLUDE'='empname')
+      """.stripMargin)
+
+    sql(
+      """
+        | CREATE TABLE listTable (empno int, empname String, designation String, doj Timestamp,
+        |  workgroupcategoryname String, deptno int, deptname String,
+        |  projectcode int, projectjoindate Timestamp, projectenddate Timestamp,attendance
int,
+        |  utilization int,salary int)
+        | PARTITIONED BY (workgroupcategory int)
+        | STORED BY 'org.apache.carbondata.format'
+        | TBLPROPERTIES('PARTITION_TYPE'='LIST',
+        |  'LIST_INFO'='0, 1, (2, 3)')
+      """.stripMargin)
+
+    sql(
+      """
+        | CREATE TABLE listTableOnString (empno int, designation String, doj Timestamp,
+        |  workgroupcategory int, workgroupcategoryname String, deptno int, deptname String,
+        |  projectcode int, projectjoindate Timestamp, projectenddate Timestamp,attendance
int,
+        |  utilization int,salary int)
+        | PARTITIONED BY (empname String)
+        | STORED BY 'org.apache.carbondata.format'
+        | TBLPROPERTIES('PARTITION_TYPE'='LIST',
+        |  'LIST_INFO'='0, 1, (2, 3)')
+      """.stripMargin)
+
+    sql(
+      """
+        | CREATE TABLE listTableOnStringNo (empno int, designation String, doj Timestamp,
+        |  workgroupcategory int, workgroupcategoryname String, deptno int, deptname String,
+        |  projectcode int, projectjoindate Timestamp, projectenddate Timestamp,attendance
int,
+        |  utilization int,salary int)
+        | PARTITIONED BY (empname String)
+        | STORED BY 'org.apache.carbondata.format'
+        | TBLPROPERTIES('PARTITION_TYPE'='LIST',
+        |  'LIST_INFO'='0, 1, (2, 3)', 'DICTIONARY_EXCLUDE'='empname')
+      """.stripMargin)
+
+    sql(s"""LOAD DATA local inpath '$resourcesPath/data.csv' INTO TABLE originTable OPTIONS('DELIMITER'=
',', 'QUOTECHAR'= '"')""")
+    sql(s"""LOAD DATA local inpath '$resourcesPath/data.csv' INTO TABLE hashTable OPTIONS('DELIMITER'=
',', 'QUOTECHAR'= '"')""")
     sql(s"""LOAD DATA local inpath '$resourcesPath/data.csv' INTO TABLE rangeTable OPTIONS('DELIMITER'=
',', 'QUOTECHAR'= '"')""")
+    sql(s"""LOAD DATA local inpath '$resourcesPath/data.csv' INTO TABLE rangeTableOnString
OPTIONS('DELIMITER'= ',', 'QUOTECHAR'= '"')""")
+    sql(s"""LOAD DATA local inpath '$resourcesPath/data.csv' INTO TABLE rangeTableOnStringNo
OPTIONS('DELIMITER'= ',', 'QUOTECHAR'= '"')""")
+    sql(s"""LOAD DATA local inpath '$resourcesPath/data.csv' INTO TABLE listTable OPTIONS('DELIMITER'=
',', 'QUOTECHAR'= '"')""")
+    sql(s"""LOAD DATA local inpath '$resourcesPath/data.csv' INTO TABLE listTableOnString
OPTIONS('DELIMITER'= ',', 'QUOTECHAR'= '"')""")
+    sql(s"""LOAD DATA local inpath '$resourcesPath/data.csv' INTO TABLE listTableOnStringNo
OPTIONS('DELIMITER'= ',', 'QUOTECHAR'= '"')""")
+
+  }
 
+  test("detail query on partition table: hash table") {
+    // EqualTo
+    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from hashTable where empno = 13"),
+      sql("select  empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empno = 13"))
+    // In
+    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from hashTable where empno in (11, 13)"),
+      sql("select  empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empno in (11, 13)"))
+  }
+
+  test("detail query on partition table: range partition") {
     // EqualTo
     checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from rangeTable where doj = '2009-07-07 00:00:00'"),
       sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where doj = '2009-07-07 00:00:00'"))
@@ -97,24 +161,51 @@ class TestQueryForPartitionTable  extends QueryTest with BeforeAndAfterAll
{
 
     checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from rangeTable where doj < '2014-08-15 00:00:00'"),
       sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where doj < '2014-08-15 00:00:00'"))
+  }
+
+  test("detail query on partition table: range partition on string") {
+    // EqualTo
+    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from rangeTableOnString where empname = 'madhan'"),
+      sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empname = 'madhan'"))
+    // In
+    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from rangeTableOnString where empname in ('tom', 'jack')"),
+      sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empname in ('tom', 'jack')"))
+    // Range
+    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from rangeTableOnString where empname >= 'tom'"),
+      sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empname >= 'tom'"))
+
+    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from rangeTableOnString where empname <= 'tom'"),
+      sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empname <= 'tom'"))
+
+    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from rangeTableOnString where empname > 'tom'"),
+      sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empname > 'tom'"))
 
-    sql("drop table rangeTable")
+    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from rangeTableOnString where empname < 'tom'"),
+      sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empname < 'tom'"))
   }
 
-  test("detail query on partition table: list partition") {
-    sql(
-      """
-        | CREATE TABLE listTable (empno int, empname String, designation String, doj Timestamp,
-        |  workgroupcategoryname String, deptno int, deptname String,
-        |  projectcode int, projectjoindate Timestamp, projectenddate Timestamp,attendance
int,
-        |  utilization int,salary int)
-        | PARTITIONED BY (workgroupcategory int)
-        | STORED BY 'org.apache.carbondata.format'
-        | TBLPROPERTIES('PARTITION_TYPE'='LIST',
-        |  'LIST_INFO'='0, 1, (2, 3)')
-      """.stripMargin)
-    sql(s"""LOAD DATA local inpath '$resourcesPath/data.csv' INTO TABLE listTable OPTIONS('DELIMITER'=
',', 'QUOTECHAR'= '"')""")
+  test("detail query on partition table: range partition on string no dictionary") {
+    // EqualTo
+    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from rangeTableOnStringNo where empname = 'madhan'"),
+      sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empname = 'madhan'"))
+    // In
+    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from rangeTableOnStringNo where empname in ('tom', 'jack')"),
+      sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empname in ('tom', 'jack')"))
+    // Range
+    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from rangeTableOnStringNo where empname >= 'tom'"),
+      sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empname >= 'tom'"))
+
+    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from rangeTableOnStringNo where empname <= 'tom'"),
+      sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empname <= 'tom'"))
 
+    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from rangeTableOnStringNo where empname > 'tom'"),
+      sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empname > 'tom'"))
+
+    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from rangeTableOnStringNo where empname < 'tom'"),
+      sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empname < 'tom'"))
+  }
+
+  test("detail query on partition table: list partition") {
     // EqualTo
     checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from listTable where workgroupcategory = 2"),
       sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where workgroupcategory = 2"))
@@ -135,8 +226,48 @@ class TestQueryForPartitionTable  extends QueryTest with BeforeAndAfterAll
{
 
     checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from listTable where workgroupcategory < 2"),
       sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where workgroupcategory < 2"))
+  }
+
+  test("detail query on partition table: list partition on string") {
+    // EqualTo
+    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from listTableOnString where empname = 'madhan'"),
+      sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empname = 'madhan'"))
+    // In
+    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from listTableOnString where empname in ('tom', 'jack')"),
+      sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empname in ('tom', 'jack')"))
+    // Range
+    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from listTableOnString where empname >= 'tom'"),
+      sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empname >= 'tom'"))
+
+    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from listTableOnString where empname <= 'tom'"),
+      sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empname <= 'tom'"))
+
+    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from listTableOnString where empname > 'tom'"),
+      sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empname > 'tom'"))
+
+    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from listTableOnString where empname < 'tom'"),
+      sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empname < 'tom'"))
+  }
+
+  test("detail query on partition table: list partition on string no dictionary") {
+    // EqualTo
+    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from listTableOnStringNo where empname = 'madhan'"),
+      sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empname = 'madhan'"))
+    // In
+    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from listTableOnStringNo where empname in ('tom', 'jack')"),
+      sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empname in ('tom', 'jack')"))
+    // Range
+    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from listTableOnStringNo where empname >= 'tom'"),
+      sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empname >= 'tom'"))
+
+    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from listTableOnStringNo where empname <= 'tom'"),
+      sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empname <= 'tom'"))
+
+    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from listTableOnStringNo where empname > 'tom'"),
+      sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empname > 'tom'"))
 
-    sql("drop table listTable")
+    checkAnswer(sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from listTableOnStringNo where empname < 'tom'"),
+      sql("select empno, empname, designation, doj, workgroupcategory, workgroupcategoryname,
deptno, deptname, projectcode, projectjoindate, projectenddate, attendance, utilization, salary
from originTable where empname < 'tom'"))
   }
 
   override def afterAll = {
@@ -149,6 +280,10 @@ class TestQueryForPartitionTable  extends QueryTest with BeforeAndAfterAll
{
     sql("drop table if exists originTable")
     sql("drop table if exists hashTable")
     sql("drop table if exists rangeTable")
+    sql("drop table if exists rangeTableOnString")
+    sql("drop table if exists rangeTableOnStringNo")
     sql("drop table if exists listTable")
+    sql("drop table if exists listTableOnString")
+    sql("drop table if exists listTableOnStringNo")
   }
 }


Mime
View raw message