carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jack...@apache.org
Subject [44/50] [abbrv] carbondata git commit: [CARBONDATA-1514] Sort Column Property is not getting added in case of alter operation
Date Tue, 10 Oct 2017 03:08:31 GMT
[CARBONDATA-1514] Sort Column Property is not getting added in case of alter operation

Problem:: Sort Column Property is not getting added in case of alter operation
Solution: Need to add sort column if use has added in alter operation

This closes #1382


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

Branch: refs/heads/streaming_ingest
Commit: a7c36ef4cb3b2652748e71b782fc8475502efa21
Parents: a734add
Author: kumarvishal <kumarvishal.1802@gmail.com>
Authored: Mon Sep 25 17:45:10 2017 +0530
Committer: ravipesala <ravi.pesala@gmail.com>
Committed: Thu Oct 5 16:43:15 2017 +0530

----------------------------------------------------------------------
 .../command/carbonTableSchemaCommon.scala         | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/a7c36ef4/integration/spark-common/src/main/scala/org/apache/spark/sql/execution/command/carbonTableSchemaCommon.scala
----------------------------------------------------------------------
diff --git a/integration/spark-common/src/main/scala/org/apache/spark/sql/execution/command/carbonTableSchemaCommon.scala
b/integration/spark-common/src/main/scala/org/apache/spark/sql/execution/command/carbonTableSchemaCommon.scala
index ebd1c6c..1a39741 100644
--- a/integration/spark-common/src/main/scala/org/apache/spark/sql/execution/command/carbonTableSchemaCommon.scala
+++ b/integration/spark-common/src/main/scala/org/apache/spark/sql/execution/command/carbonTableSchemaCommon.scala
@@ -189,6 +189,14 @@ class AlterTableColumnSchemaGenerator(
 
   val LOGGER = LogServiceFactory.getLogService(this.getClass.getName)
 
+  def isSortColumn(columnName: String): Boolean = {
+    val sortColumns = alterTableModel.tableProperties.get("sort_columns")
+    if(sortColumns.isDefined) {
+      sortColumns.get.contains(columnName)
+    } else {
+      true
+    }
+  }
   def process: Seq[ColumnSchema] = {
     val tableSchema = tableInfo.getFactTable
     val tableCols = tableSchema.getListOfColumns.asScala
@@ -208,7 +216,8 @@ class AlterTableColumnSchemaGenerator(
         -1,
         field.precision,
         field.scale,
-        field.schemaOrdinal + existingColsSize)
+        field.schemaOrdinal + existingColsSize,
+        isSortColumn(field.name.getOrElse(field.column)))
       allColumns ++= Seq(columnSchema)
       newCols ++= Seq(columnSchema)
     })
@@ -225,7 +234,8 @@ class AlterTableColumnSchemaGenerator(
         -1,
         field.precision,
         field.scale,
-        field.schemaOrdinal + existingColsSize)
+        field.schemaOrdinal + existingColsSize,
+        false)
       allColumns ++= Seq(columnSchema)
       newCols ++= Seq(columnSchema)
     })
@@ -291,7 +301,8 @@ class AlterTableColumnSchemaGenerator(
 
   private def getColumnSchema(dataType: DataType, colName: String, isCol: Boolean,
       encoders: java.util.List[Encoding], isDimensionCol: Boolean,
-      colGroup: Integer, precision: Integer, scale: Integer, schemaOrdinal: Int): ColumnSchema
= {
+      colGroup: Integer, precision: Integer, scale: Integer, schemaOrdinal: Int,
+      isSortColumn: Boolean): ColumnSchema = {
     val columnSchema = new ColumnSchema()
     columnSchema.setDataType(dataType)
     columnSchema.setColumnName(colName)
@@ -319,6 +330,7 @@ class AlterTableColumnSchemaGenerator(
     columnSchema.setScale(scale)
     columnSchema.setSchemaOrdinal(schemaOrdinal)
     columnSchema.setUseInvertedIndex(isDimensionCol)
+    columnSchema.setSortColumn(isSortColumn)
     columnSchema
   }
 }


Mime
View raw message