rdblue commented on code in PR #18108:
URL: https://github.com/apache/iceberg/pull/18108#discussion_r4149015819


##########
core/src/test/java/org/apache/iceberg/TestTrackedFileStruct.java:
##########
@@ -387,6 +461,38 @@ void 
serializationRoundTrip(RoundTripSerializer<TrackedFileStruct> serializer) t
     assertThat(deserialized.equalityIds()).containsExactly(1, 2, 3);
   }
 
+  @ParameterizedTest
+  @MethodSource("org.apache.iceberg.TestHelpers#serializers")
+  void 
partitionProjectionSurvivesSerialization(RoundTripSerializer<TrackedFileStruct> 
serializer)
+      throws Exception {
+    Schema schema =
+        new Schema(
+            Types.NestedField.required(1, "id", Types.IntegerType.get()),
+            Types.NestedField.required(2, "category", Types.StringType.get()));
+    PartitionSpec idSpec =
+        PartitionSpec.builderFor(schema)
+            .withSpecId(0)
+            .add(1, 1000, "id", Transforms.identity())
+            .build();
+    PartitionSpec categorySpec =
+        PartitionSpec.builderFor(schema)
+            .withSpecId(1)
+            .add(2, 1001, "category", Transforms.identity())
+            .build();
+    Map<Integer, PartitionSpec> specsById =
+        ImmutableMap.of(idSpec.specId(), idSpec, categorySpec.specId(), 
categorySpec);
+
+    Types.StructType unionType = 
Partitioning.unionPartitionTypes(specsById.values());
+    PartitionData unionPartition = new PartitionData(unionType);
+    
unionPartition.set(unionType.fields().indexOf(unionType.field("category")), 
"books");
+
+    TrackedFileStruct file = trackedFile(categorySpec.specId(), 
unionPartition);
+    file.setPartitionProjection(StructProjection.create(unionType, 
categorySpec.partitionType()));
+
+    TrackedFileStruct deserialized = serializer.apply((TrackedFileStruct) 
file.copy());

Review Comment:
   Calling `file.copy` here compromises this test because the actual 
`TrackedFileStruct` doesn't produce the right data when serialized. But if you 
copy it first, it does.
   
   I think this is okay behavior, especially since we are likely going to 
remove the partition. Let's fix this by updating the test name. Just add 
"AfterCopy" to the end.



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