danny0405 commented on code in PR #18723:
URL: https://github.com/apache/hudi/pull/18723#discussion_r3308328971
##########
hudi-client/hudi-flink-client/src/main/java/org/apache/hudi/util/AvroToRowDataConverters.java:
##########
@@ -143,19 +173,34 @@ public static AvroToRowDataConverter
createConverter(LogicalType type, boolean u
return createTimestampConverter(((TimestampType) type).getPrecision(),
utcTimezone);
case CHAR:
case VARCHAR:
- return avroObject -> avroObject instanceof Utf8 ?
StringData.fromBytes(((Utf8) avroObject).getBytes()) :
StringData.fromString(avroObject.toString());
+ return avroObject -> avroObject instanceof Utf8
+ ? StringData.fromBytes(((Utf8) avroObject).getBytes())
+ : StringData.fromString(avroObject.toString());
case BINARY:
case VARBINARY:
return AvroToRowDataConverters::convertToBytes;
case DECIMAL:
return createDecimalConverter((DecimalType) type);
case ARRAY:
- return createArrayConverter((ArrayType) type, utcTimezone);
+ if (nonNullSchema.getType() == HoodieSchemaType.VECTOR) {
+ HoodieSchema.Vector vectorSchema = (HoodieSchema.Vector)
nonNullSchema;
+ VectorConversionUtils.validateVectorLogicalType(vectorSchema, type);
+ return createVectorConverter(vectorSchema);
+ }
+ return createArrayConverter(nonNullSchema.getElementType(),
(ArrayType) type, utcTimezone);
case ROW:
- return createRowConverter((RowType) type, utcTimezone);
+ if (nonNullSchema.getType() == HoodieSchemaType.UNION) {
+ // getNonNullType() unwraps simple nullable unions only. Complex
unions can still reach
+ // here when their Flink representation is a ROW, for example fields
inside
+ // ColumnStatsSchemas.METADATA_SCHEMA. In that case the RowType
already captures the
+ // target Flink shape, so use the first union branch only as the
positional Hoodie schema
+ // template for building nested field converters.
+ nonNullSchema = nonNullSchema.getTypes().get(0);
Review Comment:
can we initially initialize the nonNullSchema in good shape?
--
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]