[SPARK-56043][SQL] Wrap NullPointerException from Avro 1.12.x ParseContext.resolve() in SchemaParseException#54876
Closed
jerrypeng wants to merge 3 commits intoapache:masterfrom
Closed
[SPARK-56043][SQL] Wrap NullPointerException from Avro 1.12.x ParseContext.resolve() in SchemaParseException#54876jerrypeng wants to merge 3 commits intoapache:masterfrom
jerrypeng wants to merge 3 commits intoapache:masterfrom
Conversation
….resolve() in SchemaParseException
funrollloops
approved these changes
Mar 18, 2026
HyukjinKwon
approved these changes
Mar 18, 2026
Member
|
Merged to master. |
Member
|
@jerrypeng do you want to make backport PRs? It has some minor conflicts. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Add AvroUtils.parseAvroSchema() that wraps Schema.Parser().parse() and catches NullPointerException, re-throwing it as SchemaParseException. This lets the existing parseMode-based error handling (FAILFAST → MALFORMED_AVRO_MESSAGE, PERMISSIVE → null row) work correctly. All call sites (AvroDataToCatalyst, CatalystDataToAvro, SchemaOfAvro, AvroOptions, AvroOutputWriterFactory, and the schema registry variants) are updated to use it.
Why are the changes needed?
After the Avro 1.11.3 → 1.12.0 upgrade (SPARK-49014), Schema.Parser().parse() can throw NullPointerException from ParseContext.resolve() for certain invalid user-provided schemas. In Avro 1.11.x, the same schemas threw SchemaParseException, which was caught by the existing NonFatal(e) handler in AvroDataToCatalyst.nullSafeEval and reported as MALFORMED_AVRO_MESSAGE. The NPE bypasses nothing — it's still NonFatal — but it surfaces as an unclassified internal error rather than a schema parse error because it was never expected from schema parsing.
Does this PR introduce any user-facing change?
no
How was this patch tested?
tests added
Was this patch authored or co-authored using generative AI tooling?
yes
Generated-by: claude