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


##########
flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/source/RowDataToAvroGenericRecordConverter.java:
##########
@@ -41,17 +44,114 @@
 public class RowDataToAvroGenericRecordConverter implements Function<RowData, 
GenericRecord> {
   private final RowDataToAvroConverters.RowDataToAvroConverter converter;
   private final Schema avroSchema;
+  private final RowType rowType;
 
   private RowDataToAvroGenericRecordConverter(RowType rowType, Schema 
avroSchema) {
     this.converter = RowDataToAvroConverters.createConverter(rowType);
     this.avroSchema = avroSchema;
+    this.rowType = rowType;
   }
 
   @Override
   public GenericRecord apply(RowData rowData) {
+    // Check if schema has timestamp-nanos fields
+    if (needsCustomConversion(avroSchema)) {
+      return convertWithNanos(rowData);
+    }
     return (GenericRecord) converter.convert(avroSchema, rowData);
   }
 
+  private boolean needsCustomConversion(Schema schema) {
+    for (Schema.Field field : schema.getFields()) {
+      if (field.schema().getLogicalType() instanceof 
LogicalTypes.TimestampNanos) {
+        return true;
+      }
+    }
+    return false;

Review Comment:
   Use stream API



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