kbendick commented on code in PR #4668:
URL: https://github.com/apache/iceberg/pull/4668#discussion_r861455978


##########
core/src/test/java/org/apache/iceberg/TestMetadataUpdateParser.java:
##########
@@ -197,4 +315,55 @@ private static void assertEqualsSetDefaultPartitionSpec(
       MetadataUpdate.SetDefaultPartitionSpec expected, 
MetadataUpdate.SetDefaultPartitionSpec actual) {
     Assertions.assertThat(actual.specId()).isEqualTo(expected.specId());
   }
+
+  private static void assertEqualsAddPartitionSpec(
+      MetadataUpdate.AddPartitionSpec expected, 
MetadataUpdate.AddPartitionSpec actual) {
+    Assert.assertEquals("Unbound partition specs should have the same spec id",
+        expected.spec().specId(), actual.spec().specId());
+    Assert.assertEquals("Unbound partition specs should have the same number 
of fields",
+        expected.spec().fields().size(), actual.spec().fields().size());
+
+    // Sort the fields so that we can compare them field by field
+    
expected.spec().fields().sort(Comparator.comparing(UnboundPartitionSpec.UnboundPartitionField::transformAsString));
+    
actual.spec().fields().sort(Comparator.comparing(UnboundPartitionSpec.UnboundPartitionField::transformAsString));
+    IntStream.range(0, expected.spec().fields().size())
+        .forEachOrdered(i -> {
+            UnboundPartitionSpec.UnboundPartitionField expectedField = 
expected.spec().fields().get(i);
+            UnboundPartitionSpec.UnboundPartitionField actualField = 
actual.spec().fields().get(i);
+            Assert.assertTrue(
+                "Fields of the unbound partition spec should be the same",
+                Objects.equals(expectedField.partitionId(), 
actualField.partitionId()) &&
+                    expectedField.name().equals(actualField.name()) &&
+                    Objects.equals(expectedField.transformAsString(), 
actualField.transformAsString()) &&
+                    expectedField.sourceId() == actualField.sourceId());
+        });

Review Comment:
   `UnboundPartitionField` does not implement equals or hashCode. It also 
doesn't actually inherit from `PartitionField`, so none of the methods for 
checking if they're the same can be used.
   
   Given the complexity of this code, it might make more sense to simply 
implement `equals` for this class. Open to feedback on this.



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