carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jack...@apache.org
Subject carbondata git commit: [CARBONDATA-1430] Resolved Split Partition Bug When Extra Space was Present in the NewList
Date Wed, 06 Sep 2017 14:08:57 GMT
Repository: carbondata
Updated Branches:
  refs/heads/master 1f1889e6a -> 0c519c425


[CARBONDATA-1430] Resolved Split Partition Bug When Extra Space was Present in the NewList

This closes #1298


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

Branch: refs/heads/master
Commit: 0c519c42559fba96f8317aa0143eedb9742dcc1e
Parents: 1f1889e
Author: nehabhardwaj01 <bhardwaj.neha18@gmail.com>
Authored: Wed Sep 6 19:16:36 2017 +0530
Committer: Jacky Li <jacky.likun@qq.com>
Committed: Wed Sep 6 22:08:46 2017 +0800

----------------------------------------------------------------------
 .../carbondata/spark/util/CommonUtil.scala      |  2 +-
 .../partition/TestAlterPartitionTable.scala     | 43 ++++++++++++++++++++
 2 files changed, 44 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/0c519c42/integration/spark-common/src/main/scala/org/apache/carbondata/spark/util/CommonUtil.scala
----------------------------------------------------------------------
diff --git a/integration/spark-common/src/main/scala/org/apache/carbondata/spark/util/CommonUtil.scala
b/integration/spark-common/src/main/scala/org/apache/carbondata/spark/util/CommonUtil.scala
index 5cdeb05..4f4faff 100644
--- a/integration/spark-common/src/main/scala/org/apache/carbondata/spark/util/CommonUtil.scala
+++ b/integration/spark-common/src/main/scala/org/apache/carbondata/spark/util/CommonUtil.scala
@@ -347,7 +347,7 @@ object CommonUtil {
       sys.error("The size of new list must be smaller than original list, please check again!")
     }
     val tempList = newListInfo.mkString(",").split(",")
-      .map(_.trim.replace("(", "").replace(")", ""))
+      .map(_.replace("(", "").replace(")", "").trim)
     if (tempList.length != originListInfo.size) {
       sys.error("The total number of elements in new list must equal to original list!")
     }

http://git-wip-us.apache.org/repos/asf/carbondata/blob/0c519c42/integration/spark2/src/test/scala/org/apache/carbondata/spark/testsuite/partition/TestAlterPartitionTable.scala
----------------------------------------------------------------------
diff --git a/integration/spark2/src/test/scala/org/apache/carbondata/spark/testsuite/partition/TestAlterPartitionTable.scala
b/integration/spark2/src/test/scala/org/apache/carbondata/spark/testsuite/partition/TestAlterPartitionTable.scala
index 0bbd143..090a636 100644
--- a/integration/spark2/src/test/scala/org/apache/carbondata/spark/testsuite/partition/TestAlterPartitionTable.scala
+++ b/integration/spark2/src/test/scala/org/apache/carbondata/spark/testsuite/partition/TestAlterPartitionTable.scala
@@ -435,6 +435,49 @@ class TestAlterPartitionTable extends QueryTest with BeforeAndAfterAll
{
     checkAnswer(result_after5, result_origin5)
   }
 
+  test("Alter table split partition with extra space in New SubList: List Partition") {
+    sql("""ALTER TABLE list_table_area ADD PARTITION ('(One,Two, Three, Four)')""".stripMargin)
+    sql("""ALTER TABLE list_table_area SPLIT PARTITION(4) INTO ('One', '(Two, Three )', 'Four')""".stripMargin)
+    val carbonTable = CarbonMetadata.getInstance().getCarbonTable("default_list_table_area")
+    val partitionInfo = carbonTable.getPartitionInfo(carbonTable.getFactTableName)
+    val partitionIds = partitionInfo.getPartitionIds
+    val list_info = partitionInfo.getListInfo
+    assert(partitionIds == List(0, 1, 2, 3, 5, 6, 7).map(Integer.valueOf(_)).asJava)
+    assert(partitionInfo.getMAX_PARTITION == 7)
+    assert(partitionInfo.getNumPartitions == 7)
+    assert(list_info.get(0).get(0) == "Asia")
+    assert(list_info.get(1).get(0) == "America")
+    assert(list_info.get(2).get(0) == "Europe")
+    assert(list_info.get(3).get(0) == "One")
+    assert(list_info.get(4).get(0) == "Two")
+    assert(list_info.get(4).get(1) == "Three")
+    assert(list_info.get(5).get(0) == "Four")
+    validateDataFiles("default_list_table_area", "0", Seq(0, 1, 2))
+    val result_after = sql("""select id, vin, logdate, phonenumber, country, area, salary
from list_table_area""")
+    val result_origin = sql("""select id, vin, logdate, phonenumber, country, area, salary
from list_table_area_origin""")
+    checkAnswer(result_after, result_origin)
+
+    val result_after1 = sql("""select id, vin, logdate, phonenumber, country, area, salary
from list_table_area where area < 'Four' """)
+    val result_origin1 = sql("""select id, vin, logdate, phonenumber, country, area, salary
from list_table_area_origin where area < 'Four' """)
+    checkAnswer(result_after1, result_origin1)
+
+    val result_after2 = sql("""select id, vin, logdate, phonenumber, country, area, salary
from list_table_area where area <= 'Four' """)
+    val result_origin2 = sql("""select id, vin, logdate, phonenumber, country, area, salary
from list_table_area_origin where area <= 'Four' """)
+    checkAnswer(result_after2, result_origin2)
+
+    val result_after3 = sql("""select id, vin, logdate, phonenumber, country, area, salary
from list_table_area where area = 'Four' """)
+    val result_origin3 = sql("""select id, vin, logdate, phonenumber, country, area, salary
from list_table_area_origin where area = 'Four' """)
+    checkAnswer(result_after3, result_origin3)
+
+    val result_after4 = sql("""select id, vin, logdate, phonenumber, country, area, salary
from list_table_area where area >= 'Four' """)
+    val result_origin4 = sql("""select id, vin, logdate, phonenumber, country, area, salary
from list_table_area_origin where area >= 'Four' """)
+    checkAnswer(result_after4, result_origin4)
+
+    val result_after5 = sql("""select id, vin, logdate, phonenumber, country, area, salary
from list_table_area where area > 'Four' """)
+    val result_origin5 = sql("""select id, vin, logdate, phonenumber, country, area, salary
from list_table_area_origin where area > 'Four' """)
+    checkAnswer(result_after5, result_origin5)
+  }
+
   test("Alter table split partition: Range Partition") {
     sql("""ALTER TABLE range_table_logdate_split SPLIT PARTITION(4) INTO ('2017/01/01', '2018/01/01')""")
     val carbonTable = CarbonMetadata.getInstance().getCarbonTable("default_range_table_logdate_split")


Mime
View raw message