pvary commented on a change in pull request #2219:
URL: https://github.com/apache/hive/pull/2219#discussion_r620432398



##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/AbstractAlterTableOperation.java
##########
@@ -138,8 +141,32 @@ private void finalizeAlterTableWithWriteIdOp(Table table, 
Table oldTable, List<P
       
environmentContext.putToProperties(HiveMetaHook.ALTER_TABLE_OPERATION_TYPE, 
desc.getType().name());
       if (partitions == null) {
         long writeId = desc.getWriteId() != null ? desc.getWriteId() : 0;
-        context.getDb().alterTable(desc.getDbTableName(), table, 
desc.isCascade(), environmentContext, true,
-            writeId);
+        try {
+          context.getDb().alterTable(desc.getDbTableName(), table, 
desc.isCascade(), environmentContext, true, writeId);
+        } catch (HiveException ex) {
+          if 
(environmentContext.getProperties().containsKey(HiveMetaHook.INITIALIZE_ROLLBACK_ALTER)
 && Boolean
+              
.valueOf(environmentContext.getProperties().get(HiveMetaHook.INITIALIZE_ROLLBACK_ALTER)))
 {
+            // in case of rollback of alter table do the following:
+            // 1. drop the already altered table but keep the data files
+            // 2. recreate the original table
+            // 3. run msck repair to sync partitions on filesystem with 
metastore

Review comment:
       That's what I fear. We might end up adding partitions which are on the 
FS but intentionally not has not been added to the table yet. Also I seem to 
recall that we had issues with `MSCK REPAIR` if the file naming was not correct 
(wrong order of partition keys, or wrong type of values - not valid number for 
an int column etc...)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to