pvary commented on code in PR #14245:
URL: https://github.com/apache/iceberg/pull/14245#discussion_r2414545825
##########
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)) {
Review Comment:
I don't really like these custom conversions. I feel they are brittle, and
don't handle every case.
##########
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;
Review Comment:
I don't really like these custom conversions. I feel they are brittle, and
don't handle every case.
--
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]