hudi-agent commented on code in PR #18702:
URL: https://github.com/apache/hudi/pull/18702#discussion_r3206893208
##########
hudi-client/hudi-flink-client/src/main/java/org/apache/hudi/util/AvroToRowDataConverters.java:
##########
@@ -212,6 +217,25 @@ private static AvroToRowDataConverter
createMapConverter(LogicalType type, boole
};
}
+ /**
+ * Creates a converter for Flink 2.1+ VARIANT LogicalType. The converter
receives an Avro
+ * GenericRecord carrying metadata/value binary fields and produces a Flink
+ * {@code BinaryVariant}.
+ */
+ private static AvroToRowDataConverter createVariantConverter() {
Review Comment:
🤖 nit: `record.get(0)` and `record.get(1)` are opaque — could you cast to
`GenericRecord` and use `HoodieSchema.Variant.VARIANT_METADATA_FIELD` /
`VARIANT_VALUE_FIELD` for named access? The same constants are already used in
`ParquetSchemaConverter` in this PR.
<sub><i>- AI-generated; verify before applying. React 👍/👎 to flag
quality.</i></sub>
##########
hudi-client/hudi-flink-client/src/main/java/org/apache/hudi/util/RowDataToAvroConverters.java:
##########
@@ -357,5 +362,28 @@ public Object convert(HoodieSchema schema, Object object) {
}
};
}
+
+ /**
+ * Creates a converter for Flink 2.1+ VARIANT LogicalType. The converter
receives a Flink
+ * {@code Variant} object at runtime and extracts the raw metadata/value
byte arrays,
+ * then packs them into an Avro GenericRecord with the Variant schema.
+ *
+ * <p>No shredded-variant check is needed here: {@code
HoodieSchemaConverter.convertVariant()}
+ * already rejects shredded variants before a Flink type or converter is
ever constructed,
+ * and Flink 2.1 itself only supports unshredded variants (FLIP-521).
+ */
+ private static RowDataToAvroConverter createVariantConverter() {
+ return new RowDataToAvroConverter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
Review Comment:
🤖 nit: the string literals `"metadata"` and `"value"` here could use
`HoodieSchema.Variant.VARIANT_METADATA_FIELD` / `VARIANT_VALUE_FIELD` to stay
consistent with how `ParquetSchemaConverter` references the same fields in this
PR.
<sub><i>- AI-generated; verify before applying. React 👍/👎 to flag
quality.</i></sub>
--
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]