yhyyz commented on code in PR #18610:
URL: https://github.com/apache/iceberg/pull/18610#discussion_r4366902904


##########
flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/maintenance/operator/EqualityConvertReader.java:
##########
@@ -159,13 +160,17 @@ private void processDataFile(
         builder.project(readSchema).reuseContainers().build()) {
       Accessor<StructLike> posAccessor =
           readSchema.accessorForField(MetadataColumns.ROW_POSITION.fieldId());
+      // Generic records hold java.time values; the serializer expects 
Iceberg's internal
+      // representation (e.g. days for DATE, micros for TIMESTAMP).
+      InternalRecordWrapper keyWrapper = new 
InternalRecordWrapper(readSchema.asStruct());

Review Comment:
   Done. Both wrappers (data file read schema with `_pos`, and the equality 
delete key schema) are now created once in `open()`, since neither schema 
changes after the reader opens.
   



##########
flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/maintenance/operator/EqualityConvertReader.java:
##########
@@ -159,13 +160,17 @@ private void processDataFile(
         builder.project(readSchema).reuseContainers().build()) {
       Accessor<StructLike> posAccessor =
           readSchema.accessorForField(MetadataColumns.ROW_POSITION.fieldId());
+      // Generic records hold java.time values; the serializer expects 
Iceberg's internal
+      // representation (e.g. days for DATE, micros for TIMESTAMP).
+      InternalRecordWrapper keyWrapper = new 
InternalRecordWrapper(readSchema.asStruct());
       for (Record record : records) {
         long position = (long) posAccessor.get(record);
         if (existingDeletes != null && existingDeletes.isDeleted(position)) {
           continue;
         }
 
-        SerializedEqualityValues key = fieldSerializer.serializeKey(record, 
keySchema.asStruct());
+        SerializedEqualityValues key =
+            fieldSerializer.serializeKey(keyWrapper.wrap(record), 
keySchema.asStruct());

Review Comment:
   Thanks @pvary and @mxm. I added a javadoc to 
`StructLikeSerializer.serializeKey` stating that values must use Iceberg's 
internal representation and that generic `Record`s need to be wrapped with 
`InternalRecordWrapper` first.
   
   I agree that a `serializeKey(Record)` signature with the wrapper owned by 
the serializer (and a rename to `RecordSerializer`) is the cleaner API, with 
explicit tests for all primitive types. I'm happy to do that as a follow-up PR, 
together with looking at nested equality columns such as `a.b`.
   



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