carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jack...@apache.org
Subject [18/54] [abbrv] carbondata git commit: [CARBONDATA-1426] Resolved Split Partition Bug When NewList sequence is different from OldList
Date Thu, 14 Sep 2017 09:20:11 GMT
[CARBONDATA-1426] Resolved Split Partition Bug When NewList sequence is different from OldList

Split Partition Raises Exception when the sequence of NewList Elements differ from OldList
Elements.
The PR is for this bug.

This closes #1299


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

Branch: refs/heads/streaming_ingest
Commit: 1f1889e6a0611993da5828b87d02704af08ec4ca
Parents: 588f009
Author: nehabhardwaj01 <bhardwaj.neha18@gmail.com>
Authored: Wed Aug 30 19:25:22 2017 +0530
Committer: Jacky Li <jacky.likun@qq.com>
Committed: Wed Sep 6 20:51:00 2017 +0800

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


http://git-wip-us.apache.org/repos/asf/carbondata/blob/1f1889e6/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 37aefcb..5cdeb05 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
@@ -351,7 +351,7 @@ object CommonUtil {
     if (tempList.length != originListInfo.size) {
       sys.error("The total number of elements in new list must equal to original list!")
     }
-    if (!originListInfo.sameElements(tempList)) {
+    if (!(tempList diff originListInfo).isEmpty) {
       sys.error("The elements in new list must exist in original list")
     }
   }

http://git-wip-us.apache.org/repos/asf/carbondata/blob/1f1889e6/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 a0cb1ef..0bbd143 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
@@ -386,6 +386,55 @@ class TestAlterPartitionTable extends QueryTest with BeforeAndAfterAll
{
     checkAnswer(result_after5, result_origin5)
   }
 
+  test("Alter table split partition with different List Sequence: List Partition") {
+    sql("""ALTER TABLE list_table_country ADD PARTITION ('(Part1, Part2, Part3, Part4)')""".stripMargin)
+    sql("""ALTER TABLE list_table_country SPLIT PARTITION(9) INTO ('Part4', 'Part2', '(Part1,
Part3)')""".stripMargin)
+    val carbonTable = CarbonMetadata.getInstance().getCarbonTable("default_list_table_country")
+    val partitionInfo = carbonTable.getPartitionInfo(carbonTable.getFactTableName)
+    val partitionIds = partitionInfo.getPartitionIds
+    val list_info = partitionInfo.getListInfo
+    assert(partitionIds == List(0, 1, 2, 3, 6, 7, 8, 5, 10, 11, 12).map(Integer.valueOf(_)).asJava)
+    assert(partitionInfo.getMAX_PARTITION == 12)
+    assert(partitionInfo.getNumPartitions == 11)
+    assert(list_info.get(0).get(0) == "China")
+    assert(list_info.get(0).get(1) == "US")
+    assert(list_info.get(1).get(0) == "UK")
+    assert(list_info.get(2).get(0) == "Japan")
+    assert(list_info.get(3).get(0) == "Canada")
+    assert(list_info.get(4).get(0) == "Russia")
+    assert(list_info.get(5).get(0) == "Good")
+    assert(list_info.get(5).get(1) == "NotGood")
+    assert(list_info.get(6).get(0) == "Korea")
+    assert(list_info.get(7).get(0) == "Part4")
+    assert(list_info.get(8).get(0) == "Part2")
+    assert(list_info.get(9).get(0) == "Part1")
+    assert(list_info.get(9).get(1) == "Part3")
+    validateDataFiles("default_list_table_country", "0", Seq(0, 1, 2, 3, 8))
+    val result_after = sql("""select id, vin, logdate, phonenumber, country, area, salary
from list_table_country""")
+    val result_origin = sql("""select id, vin, logdate, phonenumber, country, area, salary
from list_table_country_origin""")
+    checkAnswer(result_after, result_origin)
+
+    val result_after1 = sql("""select id, vin, logdate, phonenumber, country, area, salary
from list_table_country where country < 'NotGood' """)
+    val result_origin1 = sql("""select id, vin, logdate, phonenumber, country, area, salary
from list_table_country_origin where country < 'NotGood' """)
+    checkAnswer(result_after1, result_origin1)
+
+    val result_after2 = sql("""select id, vin, logdate, phonenumber, country, area, salary
from list_table_country where country <= 'NotGood' """)
+    val result_origin2 = sql("""select id, vin, logdate, phonenumber, country, area, salary
from list_table_country_origin where country <= 'NotGood' """)
+    checkAnswer(result_after2, result_origin2)
+
+    val result_after3 = sql("""select id, vin, logdate, phonenumber, country, area, salary
from list_table_country where country = 'NotGood' """)
+    val result_origin3 = sql("""select id, vin, logdate, phonenumber, country, area, salary
from list_table_country_origin where country = 'NotGood' """)
+    checkAnswer(result_after3, result_origin3)
+
+    val result_after4 = sql("""select id, vin, logdate, phonenumber, country, area, salary
from list_table_country where country >= 'NotGood' """)
+    val result_origin4 = sql("""select id, vin, logdate, phonenumber, country, area, salary
from list_table_country_origin where country >= 'NotGood' """)
+    checkAnswer(result_after4, result_origin4)
+
+    val result_after5 = sql("""select id, vin, logdate, phonenumber, country, area, salary
from list_table_country where country > 'NotGood' """)
+    val result_origin5 = sql("""select id, vin, logdate, phonenumber, country, area, salary
from list_table_country_origin where country > 'NotGood' """)
+    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