You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by ja...@apache.org on 2018/01/15 17:01:04 UTC

carbondata git commit: [CARBONDATA-1973] User Should not Be able to give the duplicate column name in partition

Repository: carbondata
Updated Branches:
  refs/heads/master 4adb87a7d -> 0d23461a9


[CARBONDATA-1973] User Should not Be able to give the duplicate column name in partition

User Should not Be able to give the duplicate column name in partition even if its case sensitive,hive also does the same

This closes #1777


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

Branch: refs/heads/master
Commit: 0d23461a9953a8ceeea7f8c348f61441b75f1c80
Parents: 4adb87a
Author: anubhav100 <an...@knoldus.in>
Authored: Mon Jan 8 16:36:25 2018 +0530
Committer: Jacky Li <ja...@qq.com>
Committed: Tue Jan 16 01:00:45 2018 +0800

----------------------------------------------------------------------
 .../StandardPartitionTableQueryTestCase.scala                  | 5 +++++
 .../org/apache/spark/sql/parser/CarbonSparkSqlParser.scala     | 6 +++++-
 2 files changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/0d23461a/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/standardpartition/StandardPartitionTableQueryTestCase.scala
----------------------------------------------------------------------
diff --git a/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/standardpartition/StandardPartitionTableQueryTestCase.scala b/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/standardpartition/StandardPartitionTableQueryTestCase.scala
index a36023e..db873d1 100644
--- a/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/standardpartition/StandardPartitionTableQueryTestCase.scala
+++ b/integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/standardpartition/StandardPartitionTableQueryTestCase.scala
@@ -239,6 +239,11 @@ class StandardPartitionTableQueryTestCase extends QueryTest with BeforeAndAfterA
     sql(s"""LOAD DATA local inpath '$resourcesPath/data.csv' INTO TABLE staticpartitionload partition(empname='ravi') OPTIONS('DELIMITER'= ',', 'QUOTECHAR'= '"')""")
   }
 
+test("Creation of partition table should fail if the colname in table schema and partition column is same even if both are case sensitive"){
+  intercept[Exception]{
+    sql("CREATE TABLE uniqdata_char2(name char,id int) partitioned by (NAME char)stored by 'carbondata' ")
+  }
+}
 
   private def verifyPartitionInfo(frame: DataFrame, partitionNames: Seq[String]) = {
     val plan = frame.queryExecution.sparkPlan

http://git-wip-us.apache.org/repos/asf/carbondata/blob/0d23461a/integration/spark2/src/main/scala/org/apache/spark/sql/parser/CarbonSparkSqlParser.scala
----------------------------------------------------------------------
diff --git a/integration/spark2/src/main/scala/org/apache/spark/sql/parser/CarbonSparkSqlParser.scala b/integration/spark2/src/main/scala/org/apache/spark/sql/parser/CarbonSparkSqlParser.scala
index 211e0ef..4b77417 100644
--- a/integration/spark2/src/main/scala/org/apache/spark/sql/parser/CarbonSparkSqlParser.scala
+++ b/integration/spark2/src/main/scala/org/apache/spark/sql/parser/CarbonSparkSqlParser.scala
@@ -200,7 +200,11 @@ class CarbonHelperSqlAstBuilder(conf: SQLConf,
          throw new MalformedCarbonCommandException("Error: Invalid partition definition")
       }
       // partition columns should not be part of the schema
-      val badPartCols = partitionFields.map(_.partitionColumn).toSet.intersect(colNames.toSet)
+      val badPartCols = partitionFields
+        .map(_.partitionColumn.toLowerCase)
+        .toSet
+        .intersect(colNames.map(_.toLowerCase).toSet)
+
       if (badPartCols.nonEmpty) {
         operationNotAllowed(s"Partition columns should not be specified in the schema: " +
                             badPartCols.map("\"" + _ + "\"").mkString("[", ",", "]"),