voonhous commented on code in PR #14311:
URL: https://github.com/apache/hudi/pull/14311#discussion_r2568571502
##########
hudi-common/src/main/java/org/apache/hudi/stats/ValueMetadata.java:
##########
@@ -234,19 +235,32 @@ public static ValueMetadata
getValueMetadata(GenericRecord columnStatsRecord) {
}
}
- public static ValueMetadata getValueMetadata(Schema fieldSchema,
HoodieIndexVersion indexVersion) {
+ /**
+ * Creates ValueMetadata from HoodieSchema for column statistics type
inference.
+ * This method uses HoodieSchema for in-memory processing while maintaining
+ * compatibility with existing Avro-based serialization.
+ *
+ * @param fieldSchema the HoodieSchema of the field
+ * @param indexVersion the index version to determine metadata format
+ * @return ValueMetadata instance for the given schema
+ * @throws IllegalArgumentException if schema is null or has unsupported
logical type
+ * @since 1.2.0
+ */
+ public static ValueMetadata getValueMetadata(HoodieSchema fieldSchema,
HoodieIndexVersion indexVersion) {
if (indexVersion.lowerThan(HoodieIndexVersion.V2)) {
return V1EmptyMetadata.get();
}
if (fieldSchema == null) {
throw new IllegalArgumentException("Field schema cannot be null");
}
- Schema valueSchema = getNonNullTypeFromUnion(fieldSchema);
+ HoodieSchema valueSchema =
HoodieSchemaUtils.getNonNullTypeFromUnion(fieldSchema);
ValueType valueType = ValueType.fromSchema(valueSchema);
if (valueType == ValueType.V1) {
- throw new IllegalArgumentException("Unsupported logical type for: " +
valueSchema.getLogicalType());
+ Schema avroSchema = valueSchema.toAvroSchema();
+ throw new IllegalArgumentException("Unsupported logical type for: " +
avroSchema.getLogicalType());
} else if (valueType == ValueType.DECIMAL) {
- return DecimalMetadata.create((LogicalTypes.Decimal)
valueSchema.getLogicalType());
+ Schema avroSchema = valueSchema.toAvroSchema();
+ return DecimalMetadata.create((LogicalTypes.Decimal)
avroSchema.getLogicalType());
Review Comment:
Done
--
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]