cshuo commented on code in PR #18702:
URL: https://github.com/apache/hudi/pull/18702#discussion_r3207392174
##########
hudi-client/hudi-flink-client/src/main/java/org/apache/hudi/util/HoodieSchemaConverter.java:
##########
@@ -553,23 +558,25 @@ private static DataType convertUnion(HoodieSchema schema)
{
}
/**
- * Converts a Variant schema to Flink's ROW type.
- * Variant is represented as ROW<`metadata` BYTES, `value` BYTES> in Flink.
+ * Converts a Variant HoodieSchema to the native Flink {@code VariantType}
DataType.
+ * Requires Flink 2.1+ at runtime; throws {@link
UnsupportedOperationException} on older versions.
*
* @param schema HoodieSchema to convert (must be a VARIANT type)
- * @return DataType representing the Variant as a ROW with binary fields
+ * @return native VariantType DataType
+ * @throws UnsupportedOperationException if Flink runtime is pre-2.1 or
variant is shredded
*/
private static DataType convertVariant(HoodieSchema schema) {
if (schema.getType() != HoodieSchemaType.VARIANT) {
throw new IllegalStateException("Expected HoodieSchema.Variant but got:
" + schema.getClass());
}
- // Variant is stored as a struct with two binary fields: metadata and
value.
- // Field order follows the Parquet spec and Iceberg convention (metadata
first, value second).
- return DataTypes.ROW(
- DataTypes.FIELD("metadata", DataTypes.BYTES().notNull()),
- DataTypes.FIELD("value", DataTypes.BYTES().notNull())
- ).notNull();
+ if (schema instanceof HoodieSchema.Variant
Review Comment:
can be removed, since line 569 ensures the type is VARIANT.
--
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]