hudi-agent commented on code in PR #19834:
URL: https://github.com/apache/hudi/pull/19834#discussion_r3927496743
##########
hudi-common/src/test/java/org/apache/hudi/common/schema/TestHoodieSchemaUtils.java:
##########
@@ -1332,6 +1346,26 @@ void testHasDecimalField() {
HoodieSchemaField.of("arrayfield",
HoodieSchema.createArray(HoodieSchema.createDecimal(10, 6)), null, null)
));
assertTrue(HoodieSchemaUtils.hasDecimalField(recordWithMapAndDecArray));
+ // Unions with two or more non-null branches used to recurse forever
(#19825)
+ HoodieSchema recordWithMultiBranchUnions =
HoodieSchema.createRecord("recordWithMultiBranchUnions", null, null, false,
+ Arrays.asList(
+ HoodieSchemaField.of("nullableStringOrInt",
HoodieSchema.createUnion(
+ HoodieSchema.create(HoodieSchemaType.NULL),
+ HoodieSchema.create(HoodieSchemaType.STRING),
+ HoodieSchema.create(HoodieSchemaType.INT)), null, null),
+ HoodieSchemaField.of("stringOrInt", HoodieSchema.createUnion(
+ HoodieSchema.create(HoodieSchemaType.STRING),
+ HoodieSchema.create(HoodieSchemaType.INT)), null, null)
+ ));
+
assertFalse(HoodieSchemaUtils.hasDecimalField(recordWithMultiBranchUnions));
+ HoodieSchema recordWithDecimalInLastBranch =
HoodieSchema.createRecord("recordWithDecimalInLastBranch", null, null, false,
+ Collections.singletonList(
Review Comment:
🤖 nit: `recordWithDecimalInLastBranch` ties the name to the decimal's
position in the union rather than what's being tested — something like
`recordWithDecimalInMultiBranchUnion` would stay accurate if branches are ever
reordered.
<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]