carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ravipes...@apache.org
Subject [1/2] carbondata git commit: alter table should support no_inverted_index
Date Mon, 12 Jun 2017 19:40:45 GMT
Repository: carbondata
Updated Branches:
  refs/heads/master c892d6beb -> d1080df44


alter table should support no_inverted_index


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

Branch: refs/heads/master
Commit: 2e2536fd2148f3a3dde7c6192aedf7797513b51b
Parents: c892d6b
Author: rahulforallp <rahul.kumar@knoldus.in>
Authored: Thu May 25 16:52:17 2017 +0530
Committer: ravipesala <ravi.pesala@gmail.com>
Committed: Tue Jun 13 01:10:02 2017 +0530

----------------------------------------------------------------------
 .../execution/command/carbonTableSchema.scala   |  3 ++
 .../sql/parser/CarbonSpark2SqlParser.scala      |  1 -
 .../vectorreader/AddColumnTestCases.scala       | 35 ++++++++++++++++++++
 3 files changed, 38 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/2e2536fd/integration/spark-common/src/main/scala/org/apache/spark/sql/execution/command/carbonTableSchema.scala
----------------------------------------------------------------------
diff --git a/integration/spark-common/src/main/scala/org/apache/spark/sql/execution/command/carbonTableSchema.scala
b/integration/spark-common/src/main/scala/org/apache/spark/sql/execution/command/carbonTableSchema.scala
index a3892af..fa5a0d6 100644
--- a/integration/spark-common/src/main/scala/org/apache/spark/sql/execution/command/carbonTableSchema.scala
+++ b/integration/spark-common/src/main/scala/org/apache/spark/sql/execution/command/carbonTableSchema.scala
@@ -253,6 +253,9 @@ class AlterTableColumnSchemaGenerator(
             }
           }
         }
+        else if (elem._1.equalsIgnoreCase("no_inverted_index")) {
+          col.getEncodingList.remove(Encoding.INVERTED_INDEX)
+        }
       }
     }
     tableSchema.setListOfColumns(allColumns.asJava)

http://git-wip-us.apache.org/repos/asf/carbondata/blob/2e2536fd/integration/spark2/src/main/scala/org/apache/spark/sql/parser/CarbonSpark2SqlParser.scala
----------------------------------------------------------------------
diff --git a/integration/spark2/src/main/scala/org/apache/spark/sql/parser/CarbonSpark2SqlParser.scala
b/integration/spark2/src/main/scala/org/apache/spark/sql/parser/CarbonSpark2SqlParser.scala
index a14f33e..af286eb 100644
--- a/integration/spark2/src/main/scala/org/apache/spark/sql/parser/CarbonSpark2SqlParser.scala
+++ b/integration/spark2/src/main/scala/org/apache/spark/sql/parser/CarbonSpark2SqlParser.scala
@@ -314,7 +314,6 @@ class CarbonSpark2SqlParser extends CarbonDDLSqlParser {
           // default value should not be converted to lower case
           val tblProps = tblProp.get
             .map(f => if (CarbonCommonConstants.TABLE_BLOCKSIZE.equalsIgnoreCase(f._1)
||
-                          CarbonCommonConstants.NO_INVERTED_INDEX.equalsIgnoreCase(f._1)
||
                           CarbonCommonConstants.COLUMN_GROUPS.equalsIgnoreCase(f._1) ||
             CarbonCommonConstants.SORT_COLUMNS.equalsIgnoreCase(f._1)) {
               throw new MalformedCarbonCommandException(

http://git-wip-us.apache.org/repos/asf/carbondata/blob/2e2536fd/integration/spark2/src/test/scala/org/apache/spark/carbondata/restructure/vectorreader/AddColumnTestCases.scala
----------------------------------------------------------------------
diff --git a/integration/spark2/src/test/scala/org/apache/spark/carbondata/restructure/vectorreader/AddColumnTestCases.scala
b/integration/spark2/src/test/scala/org/apache/spark/carbondata/restructure/vectorreader/AddColumnTestCases.scala
index cc33ab8..7a28365 100644
--- a/integration/spark2/src/test/scala/org/apache/spark/carbondata/restructure/vectorreader/AddColumnTestCases.scala
+++ b/integration/spark2/src/test/scala/org/apache/spark/carbondata/restructure/vectorreader/AddColumnTestCases.scala
@@ -372,10 +372,45 @@ class AddColumnTestCases extends QueryTest with BeforeAndAfterAll {
     sql("DROP TABLE IF EXISTS alter_no_dict")
   }
 
+  test("no inverted index load and alter table") {
+
+    sql("drop table if exists indexAlter")
+    sql(
+      """
+        CREATE TABLE IF NOT EXISTS indexAlter
+        (ID Int, date Timestamp, country String,
+        name String, phonetype String, serialname String)
+        STORED BY 'org.apache.carbondata.format'
+        TBLPROPERTIES('NO_INVERTED_INDEX'='country,name,phonetype')
+      """)
+
+    val testData2 = s"$resourcesPath/source.csv"
+
+    sql(s"""
+           LOAD DATA LOCAL INPATH '$testData2' into table indexAlter
+           """)
+
+    sql("alter table indexAlter add columns(salary String) tblproperties('no_inverted_index'='salary')")
+    sql(s"""
+           LOAD DATA LOCAL INPATH '$testData2' into table indexAlter
+           """)
+    checkAnswer(
+      sql("""
+           SELECT country, count(salary) AS amount
+           FROM indexAlter
+           WHERE country IN ('china','france')
+           GROUP BY country
+          """),
+      Seq(Row("china", 96), Row("france", 1))
+    )
+
+  }
+
   override def afterAll {
     sql("DROP TABLE IF EXISTS addcolumntest")
     sql("drop table if exists hivetable")
     sql("drop table if exists alter_sort_columns")
+    sql("drop table if exists indexAlter")
     sqlContext.setConf("carbon.enable.vector.reader", "false")
   }
 }


Mime
View raw message