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/05/16 17:48:20 UTC

[GitHub] [iceberg] szehon-ho commented on a diff in pull request #4662: Core: Metadata table queries fail if a partition column was reused in V2

szehon-ho commented on code in PR #4662:
URL: https://github.com/apache/iceberg/pull/4662#discussion_r873997931


##########
core/src/main/java/org/apache/iceberg/BaseUpdatePartitionSpec.java:
##########
@@ -103,7 +103,29 @@ class BaseUpdatePartitionSpec implements UpdatePartitionSpec {
     this.lastAssignedPartitionId = lastAssignedPartitionId;
   }
 
-  private int assignFieldId() {
+  /**
+   * Calculates a field ID to the newly added PartitionField.
+   * New field ID is assigned in every case for V1 tables, but for V2 we try to recycle a former ID if possible.
+   * @param sourceTransform - pair of source ID and transform for this PartitionField addition
+   * @return - the calculated field ID
+   */
+  private int assignFieldId(Pair<Integer, Transform<?, ?>> sourceTransform) {
+    if (formatVersion == 2 && base != null) {
+      int sourceId = sourceTransform.first();
+      Transform<?, ?> transform = sourceTransform.second();
+
+      Set<PartitionField> allHistoricalFields = Sets.newHashSet();
+      for (PartitionSpec partitionSpecpec : base.specs()) {

Review Comment:
   Typo 'partitionSpecpec'



##########
core/src/main/java/org/apache/iceberg/BaseUpdatePartitionSpec.java:
##########
@@ -103,7 +103,29 @@ class BaseUpdatePartitionSpec implements UpdatePartitionSpec {
     this.lastAssignedPartitionId = lastAssignedPartitionId;
   }
 
-  private int assignFieldId() {
+  /**
+   * Calculates a field ID to the newly added PartitionField.
+   * New field ID is assigned in every case for V1 tables, but for V2 we try to recycle a former ID if possible.
+   * @param sourceTransform - pair of source ID and transform for this PartitionField addition

Review Comment:
   Nit: I don't see many method with '-', maybe we can remove it.



-- 
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