carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akash...@apache.org
Subject [carbondata] branch master updated: [CARBONDATA-3348] Fix the case insensitive validation for duplicate sort column.
Date Tue, 03 Mar 2020 12:03:19 GMT
This is an automated email from the ASF dual-hosted git repository.

akashrn5 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/carbondata.git


The following commit(s) were added to refs/heads/master by this push:
     new 2bdfe1e  [CARBONDATA-3348] Fix the case insensitive validation for duplicate sort
column.
2bdfe1e is described below

commit 2bdfe1e6688e4a43c289ce30811dcfd35e237083
Author: Nihal kumar ojha <nihalnitn97@gmail.com>
AuthorDate: Mon Mar 2 09:46:50 2020 +0530

    [CARBONDATA-3348] Fix the case insensitive validation for duplicate sort column.
    
    Why is this PR needed?
    Currently the column name with different case(upper and lower)
    is getting considered as different columns for sort properties.
    
    What changes were proposed in this PR?
    Added the case insensitive validation for duplicate sort column.
    
    Does this PR introduce any user interface change?
    No
    
    Is any new testcase added?
    Yes
    
    This closes #3647
---
 .../scala/org/apache/carbondata/spark/util/CommonUtil.scala    | 10 ++++++----
 .../alterTable/TestAlterTableSortColumnsProperty.scala         |  9 +++++++--
 .../spark/testsuite/sortcolumns/TestSortColumns.scala          |  2 +-
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/integration/spark/src/main/scala/org/apache/carbondata/spark/util/CommonUtil.scala
b/integration/spark/src/main/scala/org/apache/carbondata/spark/util/CommonUtil.scala
index c911b48..fc7dc36 100644
--- a/integration/spark/src/main/scala/org/apache/carbondata/spark/util/CommonUtil.scala
+++ b/integration/spark/src/main/scala/org/apache/carbondata/spark/util/CommonUtil.scala
@@ -760,11 +760,13 @@ object CommonUtil {
       fields: Seq[(String, String)],
       varcharCols: Seq[String]
   ): Unit = {
-    if (sortKey.diff(sortKey.distinct).length > 0 ||
-        (sortKey.length > 1 && sortKey.contains(""))) {
+    val sortKeyLowerCase = sortKey.map(_.toLowerCase())
+    if ((sortKeyLowerCase).diff(sortKeyLowerCase.distinct).length > 0 ||
+      (sortKeyLowerCase.length > 1 && sortKeyLowerCase.contains(""))) {
       throw new MalformedCarbonCommandException(
-        "SORT_COLUMNS Either having duplicate columns : " +
-        sortKey.diff(sortKey.distinct).mkString(",") + " or it contains illegal argumnet.")
+        "SORT_COLUMNS Either contains duplicate columns : " +
+          sortKeyLowerCase.diff(sortKeyLowerCase.distinct).mkString(",") +
+          " or it contains an illegal argument.")
     }
 
     sortKey.foreach { column =>
diff --git a/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/alterTable/TestAlterTableSortColumnsProperty.scala
b/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/alterTable/TestAlterTableSortColumnsProperty.scala
index 7858fe8..bcbb6fe 100644
--- a/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/alterTable/TestAlterTableSortColumnsProperty.scala
+++ b/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/alterTable/TestAlterTableSortColumnsProperty.scala
@@ -282,12 +282,17 @@ class TestAlterTableSortColumnsProperty extends QueryTest with BeforeAndAfterAll
     ex = intercept[RuntimeException] {
       sql("alter table alter_sc_validate set tblproperties('sort_columns'=' stringField1
, intField, stringField1')")
     }
-    assert(ex.getMessage.contains("SORT_COLUMNS Either having duplicate columns : stringField1
or it contains illegal argumnet"))
+    assert(ex.getMessage.contains("SORT_COLUMNS Either contains duplicate columns : stringfield1
or it contains an illegal argument"))
 
     ex = intercept[RuntimeException] {
       sql("alter table alter_sc_validate set tblproperties('sort_columns'=' stringField ,
intField, stringField')")
     }
-    assert(ex.getMessage.contains("SORT_COLUMNS Either having duplicate columns : stringField
or it contains illegal argumnet"))
+    assert(ex.getMessage.contains("SORT_COLUMNS Either contains duplicate columns : stringfield
or it contains an illegal argument"))
+
+    ex = intercept[RuntimeException] {
+      sql("alter table alter_sc_validate set tblproperties('sort_columns'=' stringField ,
intField, stringFIELD')")
+    }
+    assert(ex.getMessage.contains("SORT_COLUMNS Either contains duplicate columns : stringfield
or it contains an illegal argument"))
 
     // not supported data type
 //    ex = intercept[RuntimeException] {
diff --git a/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/sortcolumns/TestSortColumns.scala
b/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/sortcolumns/TestSortColumns.scala
index c08eb50..7295b85 100644
--- a/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/sortcolumns/TestSortColumns.scala
+++ b/integration/spark/src/test/scala/org/apache/carbondata/spark/testsuite/sortcolumns/TestSortColumns.scala
@@ -297,7 +297,7 @@ class TestSortColumns extends QueryTest with BeforeAndAfterAll {
     val exceptionCaught = intercept[MalformedCarbonCommandException]{
       sql("CREATE TABLE sorttable1 (empno int, empname String, designation String, doj Timestamp,
workgroupcategory int, workgroupcategoryname String, deptno int, deptname String, projectcode
int, projectjoindate Timestamp, projectenddate Timestamp,attendance int,utilization int,salary
int) STORED AS carbondata tblproperties('sort_columns'='empno,empname,empno')")
     }
-    assert(exceptionCaught.getMessage.equals("SORT_COLUMNS Either having duplicate columns
: empno or it contains illegal argumnet."))
+    assert(exceptionCaught.getMessage.equals("SORT_COLUMNS Either contains duplicate columns
: empno or it contains an illegal argument."))
   }
 
   test("Test tableTwo data") {


Mime
View raw message