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

   ### What changes were proposed in this pull request?
   
   `ErrorClassesReader.get_sqlstate` returns `None` for a sub-class that does 
not declare its own `sqlState`, even when its main class declares one. This 
makes it fall back to the main class, matching `get_breaking_change_info` in 
the same file and `ErrorClassesJsonReader.getSqlState` on the JVM side.
   
   Split out of #57831; the two are unrelated, as 
`python/pyspark/errors/error-conditions.json` is a separate file and does not 
contain the condition that PR is about.
   
   ### Why are the changes needed?
   
   `getSqlState()` is public API on `PySparkException`. `NEAREST_BY_JOIN` 
declares `42604`, but:
   
   ```python
   >>> from pyspark.errors import PySparkRuntimeError
   >>> e = PySparkRuntimeError(
   ...     errorClass="NEAREST_BY_JOIN.UNSUPPORTED_MODE",
   ...     messageParameters={"mode": "invalid", "supported": "nearest"},
   ... )
   >>> print(e.getSqlState())
   None
   ```
   
   The JVM reader falls back to the main class here, so the two sides report 
different SQLSTATEs for the same condition.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. `getSqlState()` returns the main class's SQLSTATE for a sub-class 
without its own, instead of `None` — `NEAREST_BY_JOIN.*` goes from `None` to 
`42604`, the only condition affected today. Where neither level declares one, 
it still returns `None`.
   
   ### How was this patch tested?
   
   Added a case to `test_sqlstate` pinning `NEAREST_BY_JOIN.UNSUPPORTED_MODE` 
to `42604`, written test-first and confirmed failing before the fix. All 6 
tests in `pyspark.errors.tests.test_errors` pass.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (claude-fable-5, claude-opus-5)
   


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