CodingCat commented on a change in pull request #3954:
URL: https://github.com/apache/iceberg/pull/3954#discussion_r790339751
##########
File path: core/src/main/java/org/apache/iceberg/BaseUpdatePartitionSpec.java
##########
@@ -133,6 +133,11 @@ public BaseUpdatePartitionSpec addField(String name, Term
term) {
Pair<Integer, String> validationKey = Pair.of(sourceTransform.first(),
sourceTransform.second().toString());
PartitionField existing = transformToField.get(validationKey);
+ if (existing != null && deletes.contains(existing.fieldId()) &&
+
existing.transform().toString().equals(sourceTransform.second().toString())) {
Review comment:
updated
##########
File path: core/src/main/java/org/apache/iceberg/BaseUpdatePartitionSpec.java
##########
@@ -133,6 +133,11 @@ public BaseUpdatePartitionSpec addField(String name, Term
term) {
Pair<Integer, String> validationKey = Pair.of(sourceTransform.first(),
sourceTransform.second().toString());
PartitionField existing = transformToField.get(validationKey);
+ if (existing != null && deletes.contains(existing.fieldId()) &&
+
existing.transform().toString().equals(sourceTransform.second().toString())) {
+ deletes.remove(existing.fieldId());
+ return this;
+ }
Review comment:
updated
##########
File path: core/src/test/java/org/apache/iceberg/TestUpdatePartitionSpec.java
##########
@@ -477,12 +477,12 @@ public void testAddRedundantTimePartition() {
}
@Test
- public void testAddDeletedField() {
- AssertHelpers.assertThrows("Should fail adding a duplicate field",
- IllegalArgumentException.class, "Cannot add duplicate partition field",
- () -> new BaseUpdatePartitionSpec(formatVersion, PARTITIONED)
- .removeField("shard")
- .addField(bucket("id", 16))); // duplicates shard
+ public void testNoEffectAddDeletedSameField() {
+ PartitionSpec updated = new BaseUpdatePartitionSpec(formatVersion,
PARTITIONED)
+ .removeField("shard")
+ .addField(bucket("id", 16))
Review comment:
it's a good point, updated
--
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]