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

carbondata git commit: [CARBONDATA-3235] Fix Rename-Fail & Datamap-creation-Fail

Repository: carbondata
Updated Branches:
  refs/heads/master 3a41ee5df -> dd2fff269


[CARBONDATA-3235] Fix Rename-Fail & Datamap-creation-Fail

1. Alter Table Rename Table Fail

Problem: When tabe rename is success in hive, for failed in carbon data store, it would throw exception, but would not go back and undo rename in hive.

Solution: A flag to keep check if hive rename has already executed, and of the code breaks after hive rename is done, go back and undo the hive rename.

2. Create-Preagregate-Datamap Fail

Problem: When (preaggregate) datamap schema is written, but table updation is failed call CarbonDropDataMapCommand.processMetadata()
call dropDataMapFromSystemFolder() -> this is supposed to delete the folder on disk, but doesnt as the datamap is not yet updated in table,
and throws NoSuchDataMapException

Solution: Call CarbonDropTableCommand.run() instead of CarbonDropTableCommand.processDatamap().
as CarbonDropTableCommand.processData() deletes actual folders from disk.

This closes #2996


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

Branch: refs/heads/master
Commit: dd2fff269a6b416cbe0af8bd1a9e7108a02fd600
Parents: 3a41ee5
Author: namanrastogi <na...@gmail.com>
Authored: Thu Dec 13 16:09:58 2018 +0530
Committer: kumarvishal09 <ku...@gmail.com>
Committed: Wed Jan 9 14:16:20 2019 +0530

----------------------------------------------------------------------
 .../command/datamap/CarbonDropDataMapCommand.scala        |  2 +-
 .../command/schema/CarbonAlterTableRenameCommand.scala    | 10 +++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/carbondata/blob/dd2fff26/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/datamap/CarbonDropDataMapCommand.scala
----------------------------------------------------------------------
diff --git a/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/datamap/CarbonDropDataMapCommand.scala b/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/datamap/CarbonDropDataMapCommand.scala
index 54096ca..0bafe04 100644
--- a/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/datamap/CarbonDropDataMapCommand.scala
+++ b/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/datamap/CarbonDropDataMapCommand.scala
@@ -103,7 +103,7 @@ case class CarbonDropDataMapCommand(
             Some(childCarbonTable.get.getDatabaseName),
             childCarbonTable.get.getTableName,
             dropChildTable = true)
-          commandToRun.processMetadata(sparkSession)
+          commandToRun.run(sparkSession)
         }
         dropDataMapFromSystemFolder(sparkSession)
         return Seq.empty

http://git-wip-us.apache.org/repos/asf/carbondata/blob/dd2fff26/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/schema/CarbonAlterTableRenameCommand.scala
----------------------------------------------------------------------
diff --git a/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/schema/CarbonAlterTableRenameCommand.scala b/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/schema/CarbonAlterTableRenameCommand.scala
index dbf665a..01698c9 100644
--- a/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/schema/CarbonAlterTableRenameCommand.scala
+++ b/integration/spark2/src/main/scala/org/apache/spark/sql/execution/command/schema/CarbonAlterTableRenameCommand.scala
@@ -87,6 +87,7 @@ private[sql] case class CarbonAlterTableRenameCommand(
 
     var timeStamp = 0L
     var carbonTable: CarbonTable = null
+    var hiveRenameSuccess = false
     // lock file path to release locks after operation
     var carbonTableLockFilePath: String = null
     try {
@@ -139,6 +140,7 @@ private[sql] case class CarbonAlterTableRenameCommand(
           oldIdentifier,
           newIdentifier,
         oldTableIdentifier.getTablePath)
+      hiveRenameSuccess = true
 
       metastore.updateTableSchemaForAlter(
         newTableIdentifier,
@@ -165,6 +167,12 @@ private[sql] case class CarbonAlterTableRenameCommand(
       case e: ConcurrentOperationException =>
         throw e
       case e: Exception =>
+        if (hiveRenameSuccess) {
+          sparkSession.sessionState.catalog.asInstanceOf[CarbonSessionCatalog].alterTableRename(
+            newTableIdentifier,
+            oldTableIdentifier,
+            carbonTable.getAbsoluteTableIdentifier.getTableName)
+        }
         if (carbonTable != null) {
           AlterTableUtil.revertRenameTableChanges(
             newTableName,
@@ -173,7 +181,7 @@ private[sql] case class CarbonAlterTableRenameCommand(
             sparkSession)
         }
         throwMetadataException(oldDatabaseName, oldTableName,
-          s"Alter table rename table operation failed: ${e.getMessage}")
+          opName + " operation failed: " + e.getMessage)
     }
     Seq.empty
   }