aokolnychyi commented on a change in pull request #2257:
URL: https://github.com/apache/iceberg/pull/2257#discussion_r588765967
##########
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:
+1
We can even simplify it further, I guess:
```
deletes.stream()
.map(schema::findColumnName)
.collect(Collectors.toList());
```
----------------------------------------------------------------
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]