You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by ak...@apache.org on 2020/08/04 09:01:47 UTC

[carbondata] branch master updated: [CARBONDATA-3939]Exception added for index creation on long string columns

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 2b0c8c0  [CARBONDATA-3939]Exception added for index creation on long string columns
2b0c8c0 is described below

commit 2b0c8c04076e12903656781a64e78736d56dd087
Author: akkio-97 <ak...@gmail.com>
AuthorDate: Tue Jul 28 23:09:16 2020 +0530

    [CARBONDATA-3939]Exception added for index creation on long string columns
    
    Why is this PR needed?
    Index creation for long string columns are not yet supported.
    
    What changes were proposed in this PR?
    Exceptions are thrown if user tries to create the same.
    
    Does this PR introduce any user interface change?
    No
    
    Is any new testcase added?
    Yes
    
    This closes #3869
---
 .../secondaryindex/TestCreateIndexTable.scala        | 20 ++++++++++++++++++++
 .../secondaryindex/command/SICreationCommand.scala   | 10 ++++++++++
 2 files changed, 30 insertions(+)

diff --git a/index/secondary-index/src/test/scala/org/apache/carbondata/spark/testsuite/secondaryindex/TestCreateIndexTable.scala b/index/secondary-index/src/test/scala/org/apache/carbondata/spark/testsuite/secondaryindex/TestCreateIndexTable.scala
index db82152..48c58cd 100644
--- a/index/secondary-index/src/test/scala/org/apache/carbondata/spark/testsuite/secondaryindex/TestCreateIndexTable.scala
+++ b/index/secondary-index/src/test/scala/org/apache/carbondata/spark/testsuite/secondaryindex/TestCreateIndexTable.scala
@@ -370,6 +370,26 @@ class TestCreateIndexTable extends QueryTest with BeforeAndAfterAll {
     }
   }
 
+  test("index creation on long string columns") {
+    sql("drop table if exists si_table")
+    sql(
+      s"""
+         | CREATE TABLE si_table(
+         | name STRING,
+         | longstr STRING
+         | )
+         | STORED AS carbondata
+         | TBLPROPERTIES(
+         | 'LONG_STRING_COLUMNS'='longstr')
+         | """.stripMargin)
+
+    sql("drop index if exists temp_ind on si_table")
+    val thrown = intercept[Exception] {
+      sql("create index temp_ind on table si_table (longstr) AS 'carbondata'")
+    }
+    assert(thrown.getMessage.contains("one or more index columns specified contains long string column in table default.si_table. SI cannot be created on long string columns."))
+  }
+
   test("drop index on temp table") {
     sql(
       "CREATE temporary table dropindextemptable(id int,name string,city string,age int) using " +
diff --git a/integration/spark/src/main/scala/org/apache/spark/sql/secondaryindex/command/SICreationCommand.scala b/integration/spark/src/main/scala/org/apache/spark/sql/secondaryindex/command/SICreationCommand.scala
index 3b8a19b..b094962 100644
--- a/integration/spark/src/main/scala/org/apache/spark/sql/secondaryindex/command/SICreationCommand.scala
+++ b/integration/spark/src/main/scala/org/apache/spark/sql/secondaryindex/command/SICreationCommand.scala
@@ -261,6 +261,16 @@ private[sql] case class CarbonCreateSecondaryIndexCommand(
         throw new ErrorMessage(
           s"Table [$tableName] under database [$databaseName] is already an index table")
       }
+      // creation of index on long string columns are not supported
+      if (dims.filter(dimension => indexModel.columnNames
+        .contains(dimension.getColName))
+        .map(_.getDataType)
+        .exists(dataType => dataType.equals(DataTypes.VARCHAR))) {
+        throw new ErrorMessage(
+          s"one or more index columns specified contains long string column" +
+          s" in table $databaseName.$tableName. SI cannot be created on long string columns.")
+      }
+
       // Check whether index table column order is same as another index table column order
       oldIndexInfo = carbonTable.getIndexInfo
       if (null == oldIndexInfo) {