carbondata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chenliang...@apache.org
Subject carbondata git commit: [CARBONDATA-1441]resolved the bug for schema not reflect back in hive
Date Sat, 02 Sep 2017 02:53:01 GMT
Repository: carbondata
Updated Branches:
  refs/heads/master baca6f925 -> e2e6076e9


[CARBONDATA-1441]resolved the bug for schema not reflect back in hive

when you alter table in carbondata that schema is not reflect back in hive

This closes #1312


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

Branch: refs/heads/master
Commit: e2e6076e9eeeaceb5a5106f4db0dc5d575d18c6c
Parents: baca6f9
Author: anubhav100 <anubhav.tarar@knoldus.in>
Authored: Thu Aug 31 18:30:08 2017 +0530
Committer: chenliang613 <chenliang613@apache.org>
Committed: Sat Sep 2 10:52:50 2017 +0800

----------------------------------------------------------------------
 .../hive/CarbonHiveMetastoreListener.scala      | 22 +++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/e2e6076e/integration/hive/src/main/scala/org/apache/carbondata/hive/CarbonHiveMetastoreListener.scala
----------------------------------------------------------------------
diff --git a/integration/hive/src/main/scala/org/apache/carbondata/hive/CarbonHiveMetastoreListener.scala
b/integration/hive/src/main/scala/org/apache/carbondata/hive/CarbonHiveMetastoreListener.scala
index fd686ae..f7ee0ee 100644
--- a/integration/hive/src/main/scala/org/apache/carbondata/hive/CarbonHiveMetastoreListener.scala
+++ b/integration/hive/src/main/scala/org/apache/carbondata/hive/CarbonHiveMetastoreListener.scala
@@ -58,8 +58,28 @@ class CarbonHiveMetastoreListener(conf: Configuration) extends MetaStorePreEvent
             }
           }
         }
+      case ALTER_TABLE =>
+        val table = preEventContext.asInstanceOf[PreAlterTableEvent].getNewTable
+        val tableProps = table.getParameters
+        if (tableProps != null &&
+            tableProps.get("spark.sql.sources.provider") == "org.apache.spark.sql.CarbonSource")
{
+          val numSchemaParts = tableProps.get("spark.sql.sources.schema.numParts")
+          if (numSchemaParts != null && !numSchemaParts.isEmpty) {
+            val schemaParts = (0 until numSchemaParts.toInt).map { index =>
+              val schemaPart = tableProps.get(s"spark.sql.sources.schema.part.$index")
+              if (schemaPart == null) {
+                throw new MetaException(s"spark.sql.sources.schema.part.$index is missing!")
+              }
+              schemaPart
+            }
+            // Stick all schemaParts back to a single schema string.
+            val schema = DataType.fromJson(schemaParts.mkString).asInstanceOf[StructType]
+            val hiveSchema = schema.map(toHiveColumn).asJava
+            table.getSd.setCols(hiveSchema)
+          }
+        }
       case _ =>
-        // do nothing
+      // do nothing
     }
   }
 


Mime
View raw message