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 2022/01/24 00:31:11 UTC

[GitHub] [iceberg] rdblue commented on a change in pull request #3954: rewriting the operation when removing and adding the same partition col with the same transformation

rdblue commented on a change in pull request #3954:
URL: https://github.com/apache/iceberg/pull/3954#discussion_r790354893



##########
File path: core/src/main/java/org/apache/iceberg/BaseUpdatePartitionSpec.java
##########
@@ -124,6 +124,17 @@ public BaseUpdatePartitionSpec addField(Term term) {
     return addField(null, term);
   }
 
+  private BaseUpdatePartitionSpec rewriteDeleteAndAddField(
+      PartitionField existing, String name, Pair<Integer, Transform<?, ?>> sourceTransform) {
+    deletes.remove(existing.fieldId());
+    if (existing.name().equals(name)) {
+      return this;
+    } else {
+      String newName = name == null ? sourceTransform.second().toString() : name;
+      return renameField(existing.name(), newName);

Review comment:
       This uses the transform's string representation as the partition field name, but that's not how we generate partition field names. In fact, the result is that we have a partition field name for bucket transforms that is invalid or must be quoted in most systems (`"bucket[16]"`).
   
   Rather than generating the name, I think that this should consider a `null` name a no-op. That is if I remove `shard` and add `bucket(16, id)` then the result should still be named shard -- there's no reason to drop the name and we avoid breaking metadata tables needlessly.
   
   However, if the name was explicitly set, then drop and and should act as a rename.
   
   In short, I think it should be this:
   
   ```java
   if (name == null || existing.name().equals(name)) {
     return this;
   } else {
     return renameField(existing.name(), name);
   }
   ```




-- 
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: issues-unsubscribe@iceberg.apache.org

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