You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "hudi-bot (via GitHub)" <gi...@apache.org> on 2025/11/30 09:23:59 UTC

[I] Fix default value parsing in JSON schema converter [hudi]

hudi-bot opened a new issue, #16322:
URL: https://github.com/apache/hudi/issues/16322

   The default value can be in the following format in the JSON schema: (1) {{{}"field":\{"type":"integer","default":"50"}{}}}, (2) {{{}"field":\{"oneOf":[{"type":"null"},\{"type":"integer","default":"60"}]}{}}}. In both cases, while the field type is integer (non-String), the default value is put as a String value. The Avro schema requires strict type match for the default value and correct ordering of types (e.g., {{{}"type":["long","null"]{}}}).  Right now the Avro schema with the default value generated is not valid, causing the following exception
   {code:java}
   Caused by: org.apache.avro.AvroTypeException: Invalid default for field field1: "0" not a ["null","long"]
   	at org.apache.avro.Schema.validateDefault(Schema.java:1576)
   	at org.apache.avro.Schema.access$500(Schema.java:91)
   	at org.apache.avro.Schema$Field.<init>(Schema.java:549)
   	at org.apache.avro.Schema.parse(Schema.java:1683)
   	at org.apache.avro.Schema.parse(Schema.java:1760)
   	at org.apache.avro.Schema.parse(Schema.java:1673)
   	at org.apache.avro.Schema$Parser.parse(Schema.java:1430)
   	at org.apache.avro.Schema$Parser.parse(Schema.java:1418)
   	at org.apache.hudi.utilities.schema.SchemaRegistryProvider.parseSchemaFromRegistry(SchemaRegistryProvider.java:79)
   	... 14 more {code}
   
   ## JIRA info
   
   - Link: https://issues.apache.org/jira/browse/HUDI-7152
   - Type: Bug
   - Fix version(s):
     - 1.1.0


-- 
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: commits-unsubscribe@hudi.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Fix default value parsing in JSON schema converter [hudi]

Posted by "nsivabalan (via GitHub)" <gi...@apache.org>.
nsivabalan commented on issue #16322:
URL: https://github.com/apache/hudi/issues/16322#issuecomment-4795579079

   This appears to be fixed on master. The `JsonToAvroSchemaConverter` (introduced in commit 3be117885f / PR #12864 for HUDI-9061) handles both reported scenarios:
   
   1. `"field":{"type":"integer","default":"50"}` — converted via the `hoodie.streamer.schemaconverter.json_to_avro.convert_default_value_type` config (default `true`), which parses the string default into a `LongNode`/`DoubleNode`/`BooleanNode` based on the resolved Avro type (`JsonToAvroSchemaConverter.java` lines 281-300).
   2. `"oneOf":[{"type":"null"},{"type":"integer","default":"60"}]` — same handling, plus `arrangeTypeOrderOnDefault` (lines 305, 405-423) reorders the union so the default-matching type (`long`) comes first, avoiding the `Invalid default for field` Avro validation error.
   
   Test coverage: `TestJsonToAvroSchemaConverter#testConvertJsonSchemaToAvroSchema` with the `not-null-default-value-schema` fixture (`hudi-utilities/src/test/resources/schema-provider/json/not-null-default-value-schema/input.json`) exercises exactly the integer/oneOf cases from this report and asserts the expected `["long","null"]` ordering with numeric defaults.
   
   Closing as resolved — please reopen if you can repro on a recent master build.


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Fix default value parsing in JSON schema converter [hudi]

Posted by "nsivabalan (via GitHub)" <gi...@apache.org>.
nsivabalan closed issue #16322: Fix default value parsing in JSON schema converter
URL: https://github.com/apache/hudi/issues/16322


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org