LuciferYang opened a new pull request, #56583: URL: https://github.com/apache/spark/pull/56583
### What changes were proposed in this pull request? `ErrorClassesJsonReader.isValidErrorClass` checks a two-part error class name (`MAIN.SUB`) with `info.subClass.get.contains(subClass)`. When the main class has no sub-classes, `info.subClass` is `None`, so `.get` throws `NoSuchElementException`. This PR changes that to `info.subClass.exists(_.contains(subClass))`, which returns `false` in that case instead of throwing, and adds a test to `SparkThrowableSuite`. ### Why are the changes needed? `isValidErrorClass` is meant to return a boolean, but it threw for this input. It is reachable from user SQL: SQL scripting handler declarations validate two-part condition names through `SparkThrowableHelper.isValidErrorClass` (in `AstBuilder`), and so does `RAISE_ERROR`. As a result a name like `DIVIDE_BY_ZERO.X` (a real top-level error class with no sub-classes) surfaced an internal `NoSuchElementException` instead of the intended "condition not found" error. ### Does this PR introduce _any_ user-facing change? Yes. Validating a two-part error condition name whose main class has no sub-classes no longer throws `NoSuchElementException`; it returns `false`, so the caller can report the proper error. Inputs that already returned without throwing are unaffected. ### How was this patch tested? Added a unit test in `SparkThrowableSuite` that covers a main class without sub-classes, a main class with sub-classes (valid and unknown sub-class), unknown main classes, and malformed names. `build/sbt 'core/testOnly *SparkThrowableSuite'` passes (34 tests). ### Was this patch authored or co-authored using generative AI tooling? 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]
