ganeshashree opened a new pull request, #57376:
URL: https://github.com/apache/spark/pull/57376

   
   
   ### What changes were proposed in this pull request?
   
   `AvroDeserializer` threw three generic `java.lang.RuntimeException`s. This 
replaces them with typed exceptions:
   
   - The `BYTES -> BinaryType` type-mismatch case now throws 
`IncompatibleSchemaException` (via `errorPrefix`), matching the five sibling 
type-mismatch cases in the same `newWriter` method that already do so.
   - The non-nullable array-element and map-value null-read cases now throw a 
`SparkRuntimeException` with a new error condition 
`AVRO_CANNOT_READ_NULL_FIELD` (SQLSTATE 22004), the read-side analog of the 
existing `AVRO_CANNOT_WRITE_NULL_FIELD`.
   
   ### Why are the changes needed?
   
   Generic `RuntimeException`s are not catchable by error class, carry no 
SQLSTATE, and (for the binary case) were inconsistent with the sibling cases in 
the same method. Spark has largely migrated runtime failures to the error-class 
framework; these sites were left behind. The write path already had a typed, 
catalogued error for the analogous non-null-field situation 
(`AVRO_CANNOT_WRITE_NULL_FIELD`); the read path now has its counterpart.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. When reading Avro data where a null appears in a non-nullable array 
element or map value, or where a `BYTES` value is not a valid Avro binary, the 
exception type and message change from a generic `RuntimeException` to a typed 
`SparkRuntimeException` / `IncompatibleSchemaException` carrying an error 
condition and SQLSTATE.
   
   ### How was this patch tested?
   
   Added unit tests in `AvroCatalystDataConversionSuite` that deserialize Avro 
data containing a null into a non-nullable Catalyst array element and map 
value, asserting the `AVRO_CANNOT_READ_NULL_FIELD` error condition and 
field-path parameter via `checkError`. Also ran `SparkThrowableSuite` 
(error-conditions.json validation), `AvroCatalystDataConversionSuite`, and 
`AvroSerdeSuite`.
   
   
   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: 
https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: 
https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., 
'[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a 
faster review.
     7. If you want to add a new configuration, please read the guideline first 
for naming configurations in
        
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the 
guideline first in
        'common/utils/src/main/resources/error/README.md'.
   -->
   
   
   ### Was this patch authored or co-authored using generative AI tooling?
   <!--
   If generative AI tooling has been used in the process of authoring this 
patch, please include the
   phrase: 'Generated-by: ' followed by the name of the tool and its version.
   If no, write 'No'.
   Please refer to the [ASF Generative Tooling 
Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
   -->
   
   Generated-by: Claude Code (Opus 4.8)


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to