difin commented on code in PR #6120:
URL: https://github.com/apache/hive/pull/6120#discussion_r2440787610


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java:
##########
@@ -776,11 +815,34 @@ private void 
handleChangeColumn(org.apache.hadoop.hive.metastore.api.Table hmsTa
         updateSchema.moveFirst(outOfOrder.first());
       }
     }
+
+    // case 5: handle change of default values
+    handleDefaultValues(defaultValues, renameMapping, 
icebergTable.schema().columns(), "");
     updateSchema.commit();
 
     handlePartitionRename(schemaDifference);
   }
 
+  private void handleDefaultValues(Map<String, String> defaultValues, 
Map<String, String> renameMapping,
+      List<Types.NestedField> columns, String prefix) {
+    if (!defaultValues.isEmpty()) {
+      for (Map.Entry<String, String> field : defaultValues.entrySet()) {
+        String simpleName =
+            renameMapping.containsKey(field.getKey()) ? 
renameMapping.get(field.getKey()) : field.getKey();
+        String qualifiedName = prefix + simpleName;
+        Type fieldType =
+            columns.stream().filter(col -> 
col.name().equalsIgnoreCase(simpleName)).findFirst().get().type();
+        if (fieldType.isStructType()) {
+          Map<String, String> structDefaults = 
HiveSchemaUtil.getDefaultValuesMap(field.getValue());
+          handleDefaultValues(structDefaults, renameMapping, 
fieldType.asStructType().fields(), qualifiedName + ".");
+        } else {
+          updateSchema.updateColumnDefault(qualifiedName,
+              Expressions.lit(HiveSchemaUtil.getDefaultValue(field.getValue(), 
fieldType)));
+        }
+      }
+    }
+  }

Review Comment:
   Can you please add a comment to explain what this method does?



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

To unsubscribe, e-mail: [email protected]

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