Repository: incubator-carbondata
Updated Branches:
  refs/heads/master 5b978f5b7 -> 9e35dc280


Fix the bug that when table properties is repeated it only set the last one

Fix the test case

Simply

Simply

Fix commmets and rebase


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

Branch: refs/heads/master
Commit: ac8c4d1880fd148337817222d9bfd0b217c8a3d5
Parents: 5b978f5
Author: Zhangshunyu <zhangshu...@huawei.com>
Authored: Wed Sep 28 12:50:01 2016 +0800
Committer: jackylk <jacky.li...@huawei.com>
Committed: Fri Oct 14 22:29:40 2016 +0800

----------------------------------------------------------------------
 .../org/apache/spark/sql/CarbonSqlParser.scala  |  9 ++++++++-
 .../createtable/TestCreateTableSyntax.scala     | 20 ++++++++++++++++++++
 .../deleteTable/TestDeleteTableNewDDL.scala     |  6 +++---
 3 files changed, 31 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/ac8c4d18/integration/spark/src/main/scala/org/apache/spark/sql/CarbonSqlParser.scala
----------------------------------------------------------------------
diff --git 
a/integration/spark/src/main/scala/org/apache/spark/sql/CarbonSqlParser.scala 
b/integration/spark/src/main/scala/org/apache/spark/sql/CarbonSqlParser.scala
index 0247aec..30760ed 100644
--- 
a/integration/spark/src/main/scala/org/apache/spark/sql/CarbonSqlParser.scala
+++ 
b/integration/spark/src/main/scala/org/apache/spark/sql/CarbonSqlParser.scala
@@ -364,7 +364,14 @@ class CarbonSqlParser()
                 }
               }
             case Token("TOK_TABLEPROPERTIES", list :: Nil) =>
-              tableProperties ++= getProperties(list)
+              val propertySeq: Seq[(String, String)] = getProperties(list)
+              val repeatedProperties = 
propertySeq.groupBy(_._1).filter(_._2.size > 1).keySet
+              if (repeatedProperties.nonEmpty) {
+                val repeatedPropStr: String = repeatedProperties.mkString(",")
+                throw new MalformedCarbonCommandException("Table properties is 
repeated: " +
+                  repeatedPropStr)
+              }
+              tableProperties ++= propertySeq
 
             case Token("TOK_LIKETABLE", child :: Nil) =>
               likeTableName = child.getChild(0).getText()

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/ac8c4d18/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/createtable/TestCreateTableSyntax.scala
----------------------------------------------------------------------
diff --git 
a/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/createtable/TestCreateTableSyntax.scala
 
b/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/createtable/TestCreateTableSyntax.scala
index b99e73f..5f8c150 100644
--- 
a/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/createtable/TestCreateTableSyntax.scala
+++ 
b/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/createtable/TestCreateTableSyntax.scala
@@ -162,6 +162,26 @@ class TestCreateTableSyntax extends QueryTest with 
BeforeAndAfterAll {
       }
     }
   }
+
+  test("create carbon table with repeated table properties") {
+    try {
+      sql(
+        """
+          CREATE TABLE IF NOT EXISTS carbontable
+          (ID Int, date Timestamp, country String,
+          name String, phonetype String, serialname String, salary Int)
+          STORED BY 'carbondata'
+          
TBLPROPERTIES('DICTIONARY_EXCLUDE'='country','DICTIONARY_INCLUDE'='ID',
+          'DICTIONARY_EXCLUDE'='phonetype', 'DICTIONARY_INCLUDE'='salary')
+        """)
+      assert(false)
+    } catch {
+      case e : MalformedCarbonCommandException => {
+        assert(e.getMessage.equals("Table properties is repeated: 
dictionary_include,dictionary_exclude"))
+      }
+    }
+  }
+
   override def afterAll {
     sql("drop table if exists carbontable")
   }

http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/ac8c4d18/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/deleteTable/TestDeleteTableNewDDL.scala
----------------------------------------------------------------------
diff --git 
a/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/deleteTable/TestDeleteTableNewDDL.scala
 
b/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/deleteTable/TestDeleteTableNewDDL.scala
index 67c2d4a..adec571 100644
--- 
a/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/deleteTable/TestDeleteTableNewDDL.scala
+++ 
b/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/deleteTable/TestDeleteTableNewDDL.scala
@@ -97,7 +97,7 @@ class TestDeleteTableNewDDL extends QueryTest with 
BeforeAndAfterAll {
       "CREATE table CaseInsensitiveTable (ID int, date String, country String, 
name " +
       "String," +
       "phonetype String, serialname String, salary int) stored by 
'org.apache.carbondata.format'" +
-      "TBLPROPERTIES('DICTIONARY_INCLUDE'='ID', 'DICTIONARY_INCLUDE'='salary')"
+      "TBLPROPERTIES('DICTIONARY_INCLUDE'='ID, salary')"
     )
     // table should drop wihout any error
     sql("drop table caseInsensitiveTable")
@@ -107,7 +107,7 @@ class TestDeleteTableNewDDL extends QueryTest with 
BeforeAndAfterAll {
       "CREATE table CaseInsensitiveTable (ID int, date String, country String, 
name " +
       "String," +
       "phonetype String, serialname String, salary int) stored by 
'org.apache.carbondata.format'" +
-      "TBLPROPERTIES('DICTIONARY_INCLUDE'='ID', 'DICTIONARY_INCLUDE'='salary')"
+      "TBLPROPERTIES('DICTIONARY_INCLUDE'='ID, salary')"
     )
 
   }
@@ -118,7 +118,7 @@ class TestDeleteTableNewDDL extends QueryTest with 
BeforeAndAfterAll {
       "CREATE table default.table3 (ID int, date String, country String, name 
" +
       "String," +
       "phonetype String, serialname String, salary int) stored by 
'org.apache.carbondata.format'" +
-      "TBLPROPERTIES('DICTIONARY_INCLUDE'='ID', 'DICTIONARY_INCLUDE'='salary')"
+      "TBLPROPERTIES('DICTIONARY_INCLUDE'='ID, salary')"
     )
     // table should drop without any error
     sql("drop table default.table3")

Reply via email to