yihua commented on code in PR #13888:
URL: https://github.com/apache/hudi/pull/13888#discussion_r2345599160
##########
hudi-common/src/test/java/org/apache/hudi/avro/TestHoodieAvroUtils.java:
##########
@@ -937,6 +938,9 @@ void testHasSmallPrecisionDecimalField() {
assertTrue(HoodieAvroUtils.hasSmallPrecisionDecimalField(new
Schema.Parser().parse(SCHEMA_WITH_DECIMAL_FIELD)));
assertFalse(HoodieAvroUtils.hasSmallPrecisionDecimalField(new
Schema.Parser().parse(SCHEMA_WITH_AVRO_TYPES_STR)));
assertFalse(HoodieAvroUtils.hasSmallPrecisionDecimalField(new
Schema.Parser().parse(EXAMPLE_SCHEMA)));
+ Schema unionSchema =
Schema.createUnion(Arrays.asList(Schema.create(Schema.Type.STRING),
Schema.create(Schema.Type.DOUBLE)));
+ assertThrows(HoodieAvroSchemaException.class,
+ () -> HoodieAvroUtils.hasSmallPrecisionDecimalField(unionSchema));
Review Comment:
Is there a valid case that the `UNION` has two non-null types and `NULL`?
##########
hudi-common/src/test/java/org/apache/hudi/avro/TestHoodieAvroUtils.java:
##########
@@ -937,6 +938,9 @@ void testHasSmallPrecisionDecimalField() {
assertTrue(HoodieAvroUtils.hasSmallPrecisionDecimalField(new
Schema.Parser().parse(SCHEMA_WITH_DECIMAL_FIELD)));
assertFalse(HoodieAvroUtils.hasSmallPrecisionDecimalField(new
Schema.Parser().parse(SCHEMA_WITH_AVRO_TYPES_STR)));
assertFalse(HoodieAvroUtils.hasSmallPrecisionDecimalField(new
Schema.Parser().parse(EXAMPLE_SCHEMA)));
+ Schema unionSchema =
Schema.createUnion(Arrays.asList(Schema.create(Schema.Type.STRING),
Schema.create(Schema.Type.DOUBLE)));
+ assertThrows(HoodieAvroSchemaException.class,
+ () -> HoodieAvroUtils.hasSmallPrecisionDecimalField(unionSchema));
Review Comment:
In that case, the fix is not strictly correct?
--
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]