You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] HoodieSchemaUtils.hasDecimalField recurses forever on a union with two or more non-null branches #19825
HoodieSchemaUtils.hasDecimalField (hasDecimalWithCondition before #19809) handles a union by recursing on schema.getNonNullType():
caseUNION:
returnhasDecimalWithCondition(schema.getNonNullType(), condition); // HoodieSchemaUtils.java:799-800 on master
HoodieSchema.getNonNullType() returns this for a union that has no null branch (HoodieSchema.java:1397-1399), and a union with one null branch and two or more non-null branches is reduced to exactly that shape (HoodieSchema.java:1413, createUnion(nonNullTypes)). So any schema containing a field typed ["null","string","int"] (or ["string","int"]) recurses until StackOverflowError.
Reachable from SourceFormatAdapter.java:261, which evaluates HoodieSchemaUtils.hasDecimalField(sourceSchema) for every JSON source whenever field-name sanitizing is off, i.e. any Hudi Streamer job with a JSON source whose provided Avro schema carries a multi-branch union. HoodieSchemaRepair.hasTimestampMillisField (HoodieSchemaRepair.java:249) has the identical arm; its caller HoodieFileGroupReaderBasedFileFormat.scala:102 receives Spark-derived schemas, which cannot carry complex unions, so it is latent there.
Present since #17600 (399af74b369f) introduced the HoodieSchema version. Not a regression from #19809, which keeps the arm unchanged.
Fix direction: iterate the branches instead of collapsing them, the shape HoodieSchema#containsBlobType (HoodieSchema.java:1427) already uses: case UNION: return schema.getTypes().stream().anyMatch(HoodieSchemaUtils::hasDecimalField);, same edit in HoodieSchemaRepair.hasTimestampMillisField, plus a multi-branch union case in TestHoodieSchemaUtils#testHasDecimalField and TestHoodieSchemaRepair.
Environment
Hudi master (c59987a024cd), any engine; Hudi Streamer with a JSON source is the reachable path
Logs and Stack Trace
java.lang.StackOverflowError
at org.apache.hudi.common.schema.HoodieSchema.getNonNullType(HoodieSchema.java:1391)
at org.apache.hudi.common.schema.HoodieSchemaUtils.hasDecimalWithCondition(HoodieSchemaUtils.java:800)
at org.apache.hudi.common.schema.HoodieSchemaUtils.hasDecimalWithCondition(HoodieSchemaUtils.java:800)
...
Activity
refactor(schema): schema util contracts, dead API and folds (#19809)
test(spark): cover member-struct unions in walks
fix(schema): stop union walks looping forever (#19834)