cloud-fan opened a new pull request, #57228:
URL: https://github.com/apache/spark/pull/57228

   ### What changes were proposed in this pull request?
   
   Replace the legacy error condition `_LEGACY_ERROR_TEMP_2228` with a 
descriptive condition `UDT_CLASS_NOT_FOUND` (SQLSTATE `38000`), part of the 
error-class migration (umbrella 
[SPARK-37935](https://issues.apache.org/jira/browse/SPARK-37935)).
   
   - Add `UDT_CLASS_NOT_FOUND` to `error-conditions.json` with two subclasses 
and remove `_LEGACY_ERROR_TEMP_2228`:
     - `FOR_USER_CLASS` — the UDT class registered for a user class via 
`UDTRegistration` cannot be loaded (replaces `_LEGACY_ERROR_TEMP_2228`).
     - `WITHOUT_USER_CLASS` — the UDT class named directly in a schema string 
cannot be loaded.
   - `DataTypeErrors.cannotLoadUserDefinedTypeError` now raises 
`UDT_CLASS_NOT_FOUND.FOR_USER_CLASS`.
   - `DataType.fromJson`'s Scala/Java UDT branch now catches 
`ClassNotFoundException` from `SparkClassUtils.classForName` and rewraps it as 
`UDT_CLASS_NOT_FOUND.WITHOUT_USER_CLASS`. Previously a raw 
`java.lang.ClassNotFoundException` (no error class, no SQLSTATE) propagated 
when a schema string (for example the schema stored in Parquet/ORC file 
metadata, or a Delta table's stored schema) referenced a UDT class that was not 
on the classpath.
   - Add tests in `DataTypeSuite` (`WITHOUT_USER_CLASS`) and 
`UDTRegistrationSuite` (`FOR_USER_CLASS`).
   
   ### Why are the changes needed?
   
   Part of the error-class migration 
([SPARK-37935](https://issues.apache.org/jira/browse/SPARK-37935)). The legacy 
condition used free-form `name`/`userClass` parameters and, for the 
`DataType.fromJson` path, a missing UDT class was not wrapped at all: a raw 
`ClassNotFoundException` propagated without any error class or SQLSTATE, so it 
could not be identified or handled programmatically. Assigning a proper name 
and SQLSTATE, and wrapping the `fromJson` path, makes both failures diagnosable.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, within the unreleased `master` branch only. The error condition name 
and SQLSTATE change (`_LEGACY_ERROR_TEMP_2228` -> 
`UDT_CLASS_NOT_FOUND.FOR_USER_CLASS`), and loading a non-existent UDT class 
named in a schema string now raises `UDT_CLASS_NOT_FOUND.WITHOUT_USER_CLASS` 
(SQLSTATE `38000`) instead of a raw `ClassNotFoundException`.
   
   ### How was this patch tested?
   
   New unit tests:
   - `DataTypeSuite`: "UDT_CLASS_NOT_FOUND.WITHOUT_USER_CLASS when UDT class is 
not on classpath".
   - `UDTRegistrationSuite`: "UDT_CLASS_NOT_FOUND.FOR_USER_CLASS when UDT class 
is not loadable".
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude 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