Skip to content

Commit

Permalink
[CARBONDATA-3235] Fix Rename-Fail & Datamap-creation-Fail
Browse files Browse the repository at this point in the history
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
  • Loading branch information
NamanRastogi authored and kumarvishal09 committed Jan 9, 2019
1 parent 3a41ee5 commit dd2fff2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Expand Up @@ -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
Expand Down
Expand Up @@ -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 {
Expand Down Expand Up @@ -139,6 +140,7 @@ private[sql] case class CarbonAlterTableRenameCommand(
oldIdentifier,
newIdentifier,
oldTableIdentifier.getTablePath)
hiveRenameSuccess = true

metastore.updateTableSchemaForAlter(
newTableIdentifier,
Expand All @@ -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,
Expand All @@ -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
}
Expand Down

0 comments on commit dd2fff2

Please sign in to comment.