[ 
https://issues.apache.org/jira/browse/HIVE-25057?focusedWorklogId=589753&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-589753
 ]

ASF GitHub Bot logged work on HIVE-25057:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 27/Apr/21 13:52
            Start Date: 27/Apr/21 13:52
    Worklog Time Spent: 10m 
      Work Description: marton-bod commented on a change in pull request #2219:
URL: https://github.com/apache/hive/pull/2219#discussion_r621229746



##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/AbstractAlterTableOperation.java
##########
@@ -146,22 +147,23 @@ private void finalizeAlterTableWithWriteIdOp(Table table, 
Table oldTable, List<P
           if (Boolean.valueOf(environmentContext.getProperties()
               .getOrDefault(HiveMetaHook.INITIALIZE_ROLLBACK_MIGRATION, 
"false"))) {
             // 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
-            context.getDb().dropTable(table.getDbName(), table.getTableName(), 
false, true, false);
-            context.getDb().createTable(oldTable);
-            Msck msck = new Msck(false, false);
-            try {
-              msck.init(Msck.getMsckConf(context.getDb().getConf()));
-              
msck.updateExpressionProxy(Msck.getProxyClass(context.getDb().getConf()));
-              MsckInfo msckInfo =
-                  new MsckInfo(table.getCatalogName(), table.getDbName(), 
table.getTableName(), null, null, true, true,
-                      true, -1);
-              msck.repair(msckInfo);
-            } catch (TException tex) {
-              throw new HiveException("Rollback of alter table cannot be 
performed", tex);
-            }
+            // 1. restore serde info and input/output format
+            // 2. remove table columns which are used to be partition columns
+            // 3. add partition columns
+            table.getSd().setInputFormat(oldTable.getSd().getInputFormat());
+            table.getSd().setOutputFormat(oldTable.getSd().getOutputFormat());
+            table.getSd().setSerdeInfo(oldTable.getSd().getSerdeInfo());
+            table.getSd().getCols().removeAll(oldTable.getPartitionKeys());
+            table.setPartCols(oldTable.getPartitionKeys());
+
+            table.getParameters().clear();
+            table.getParameters().putAll(oldTable.getParameters());
+            context.getDb().alterTable(desc.getDbTableName(), table, 
desc.isCascade(), environmentContext, true, writeId);
+            throw new HiveException("Error occurred during hive table 
migration to iceberg. Table properties "
+                + "and serde info was reverted to it's original value. 
Partition info was lost during the migration "

Review comment:
       nit: typo, its




-- 
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:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 589753)
    Time Spent: 6h 20m  (was: 6h 10m)

> Implement rollback for hive to iceberg migration
> ------------------------------------------------
>
>                 Key: HIVE-25057
>                 URL: https://issues.apache.org/jira/browse/HIVE-25057
>             Project: Hive
>          Issue Type: Improvement
>            Reporter: László Pintér
>            Assignee: László Pintér
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 6h 20m
>  Remaining Estimate: 0h
>
> This is a follow-up Jira of HIVE-25008.
> In case of an error during hive to iceberg migration, the original hive table 
> must be restored. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to