You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2021/02/26 00:56:47 UTC

[GitHub] [iceberg] RussellSpitzer commented on a change in pull request #2257: Handle metrics during schema transformation

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



##########
File path: core/src/main/java/org/apache/iceberg/SchemaUpdate.java
##########
@@ -382,27 +378,43 @@ private int assignNewColumnId() {
   }
 
   private TableMetadata applyChangesToMapping(TableMetadata metadata) {
-    String mappingJson = metadata.property(TableProperties.DEFAULT_NAME_MAPPING, null);
-    if (mappingJson != null) {
+    String existingMappingJson = metadata.property(TableProperties.DEFAULT_NAME_MAPPING, null);
+    TableMetadata ret = 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);
+        ret = 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();
+      List<String> deletedColumns = deletes.stream()
+          .map(i -> schema.findColumnName(i))

Review comment:
       a nit but I would rather it was something like "name" instead of i but it may be my bias that I assume i is an int.




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



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org