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



##########
File path: 
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java
##########
@@ -262,17 +264,52 @@ public void 
preAlterTable(org.apache.hadoop.hive.metastore.api.Table hmsTable, E
 
     if (AlterTableType.ADDCOLS.equals(currentAlterTableOp)) {
       Collection<FieldSchema> addedCols =
-          HiveSchemaUtil.schemaDifference(hmsTable.getSd().getCols(), 
HiveSchemaUtil.convert(icebergTable.schema()));
+          HiveSchemaUtil.newColumns(hmsTable.getSd().getCols(), 
HiveSchemaUtil.convert(icebergTable.schema()));
+      if (!addedCols.isEmpty()) {
+        updateSchema = icebergTable.updateSchema();
+      }
+      for (FieldSchema addedCol : addedCols) {
+        updateSchema.addColumn(
+            addedCol.getName(),
+            
HiveSchemaUtil.convert(TypeInfoUtils.getTypeInfoFromTypeString(addedCol.getType())),
+            addedCol.getComment()
+        );
+      }
+    } else if (AlterTableType.REPLACE_COLUMNS.equals(currentAlterTableOp)) {
+      List<FieldSchema> icebergSchema = 
HiveSchemaUtil.convert(icebergTable.schema());
+      List<FieldSchema> hmsSchema = hmsTable.getSd().getCols();
+      Collection<FieldSchema> droppedCols = 
HiveSchemaUtil.newColumns(icebergSchema, hmsSchema);

Review comment:
       I understand why `newColums` are used, but maybe a better name could be 
found instead of `newColumns`, like `missingColumns`?




-- 
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