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: [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]

Reply via email to