pvary commented on code in PR #14245:
URL: https://github.com/apache/iceberg/pull/14245#discussion_r2414401619


##########
flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/sink/AvroGenericRecordToRowDataMapper.java:
##########
@@ -41,13 +45,114 @@
 public class AvroGenericRecordToRowDataMapper implements 
MapFunction<GenericRecord, RowData> {
 
   private final AvroToRowDataConverters.AvroToRowDataConverter converter;
+  private final Schema avroSchema;
+  private final Function<GenericRecord, RowData> customConverter;
 
-  AvroGenericRecordToRowDataMapper(RowType rowType) {
+  AvroGenericRecordToRowDataMapper(RowType rowType, Schema avroSchema) {
+    this.avroSchema = avroSchema;
     this.converter = AvroToRowDataConverters.createRowConverter(rowType);
+    // Check if we need custom conversion for timestamp-nanos
+    this.customConverter = needsCustomConversion(avroSchema) ? 
this::convertWithNanos : null;
+  }
+
+  private boolean needsCustomConversion(Schema schema) {
+    for (Schema.Field field : schema.getFields()) {
+      if (field.schema().getLogicalType() instanceof 
LogicalTypes.TimestampNanos) {
+        return true;
+      }
+    }
+    return false;
+  }

Review Comment:
   Maybe:
   ```
       return schema.getFields().stream()
           .anyMatch(field -> field.schema().getLogicalType() instanceof 
LogicalTypes.TimestampNanos);
   ```



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