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 54096ca75fc..0bafe0451fc 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 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 dbf665a865e..87d7402c41c 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( + TableIdentifier(newTableName, Some(oldDatabaseName)), + TableIdentifier(oldTableName, Some(oldDatabaseName)), + carbonTable.getAbsoluteTableIdentifier.getTableName) + } if (carbonTable != null) { AlterTableUtil.revertRenameTableChanges( newTableName, @@ -172,8 +180,9 @@ private[sql] case class CarbonAlterTableRenameCommand( timeStamp)( sparkSession) } + LOGGER.error(opName + " operation failed: ", e) throwMetadataException(oldDatabaseName, oldTableName, - s"Alter table rename table operation failed: ${e.getMessage}") + opName + " operation failed! Please check logs for details.") } Seq.empty }