rdblue commented on a change in pull request #3421:
URL: https://github.com/apache/iceberg/pull/3421#discussion_r739885078
##########
File path: api/src/main/java/org/apache/iceberg/PartitionSpec.java
##########
@@ -350,6 +351,35 @@ private void checkAndAddPartitionName(String name, Integer
sourceColumnId) {
}
Preconditions.checkArgument(name != null && !name.isEmpty(),
"Cannot use empty or null partition name: %s", name);
+
+ // Rename existing void transformation that conflict with this new name.
This is an issue with V1 tables which
+ // use void transforms to preserve spec ordering. Void transform names
do not matter and
+ // by default they take the name of the column which was removed. If we
attempt to add partitioning on the
+ // column back we can change the name of the void transform to allow for
this. Currently, BaseUpdatePartitionSpec
+ // should avoid this by adding the field ID to any new void transforms
but for tables made before that change
+ // the modification below is still needed.
+ if (partitionNames.contains(name)) {
+ int existingFieldIndex = Iterables.indexOf(fields, field ->
field.name().equals(name));
+ PartitionField existingField = fields.get(existingFieldIndex);
+ if (existingField.transform().equals(Transforms.alwaysNull())) {
+ String newName = name + "_" + existingField.fieldId();
+ while (partitionNames.contains(newName)) {
+ // On the off chance someone names a partition field very strangely
Review comment:
Seems a bit overkill, but okay.
--
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]