aokolnychyi commented on a change in pull request #2257:
URL: https://github.com/apache/iceberg/pull/2257#discussion_r630516958



##########
File path: core/src/main/java/org/apache/iceberg/SchemaUpdate.java
##########
@@ -401,28 +396,43 @@ private int assignNewColumnId() {
     return next;
   }
 
-  private TableMetadata applyChangesToMapping(TableMetadata metadata) {
-    String mappingJson = 
metadata.property(TableProperties.DEFAULT_NAME_MAPPING, null);
-    if (mappingJson != null) {
+  private TableMetadata applyChangesToMetadata(TableMetadata metadata) {
+    String existingMappingJson = 
metadata.property(TableProperties.DEFAULT_NAME_MAPPING, null);
+    TableMetadata newMetadata = metadata;
+    if (existingMappingJson != null) {
       try {
         // parse and update the mapping
-        NameMapping mapping = NameMappingParser.fromJson(mappingJson);
+        NameMapping mapping = NameMappingParser.fromJson(existingMappingJson);
         NameMapping updated = MappingUtil.update(mapping, updates, adds);
 
         // replace the table property
         Map<String, String> updatedProperties = Maps.newHashMap();
         updatedProperties.putAll(metadata.properties());
         updatedProperties.put(TableProperties.DEFAULT_NAME_MAPPING, 
NameMappingParser.toJson(updated));
 
-        return metadata.replaceProperties(updatedProperties);
+        newMetadata = metadata.replaceProperties(updatedProperties);
 
       } catch (RuntimeException e) {
         // log the error, but do not fail the update
-        LOG.warn("Failed to update external schema mapping: {}", mappingJson, 
e);
+        LOG.warn("Failed to update external schema mapping: {}", 
existingMappingJson, e);
       }
     }
 
-    return metadata;
+    // Transform the metrics if they exist
+    if (base != null && base.properties() != null) {
+      Schema newSchema = metadata.schema();

Review comment:
       nit: it probably does not matter now but shall we use `newMetadata` here 
in case if the logic above changes?




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