j1wonpark commented on code in PR #57887:
URL: https://github.com/apache/spark/pull/57887#discussion_r3754320815
##########
python/pyspark/errors/utils.py:
##########
@@ -98,20 +98,22 @@ def __init__(self) -> None:
def get_sqlstate(self, errorClass: Optional[str]) -> Optional[str]:
"""
Returns the SQL state for the given error class.
+
+ A sub-class with its own sqlState overrides the main class's; a
sub-class
+ without one inherits the main class's.
Review Comment:
Correct, inheritance is the only intent. Dropped the override branch and
reworded the docstring. The lookup is `split(".")[0]` only now, same as
`ErrorClassesJsonReader.getSqlState` on the JVM side.
##########
python/pyspark/errors/tests/test_errors.py:
##########
@@ -118,12 +118,20 @@ def test_sqlstate(self):
error = PySparkRuntimeError(errorClass="APPLICATION_NAME_NOT_SET",
messageParameters={})
self.assertIsNone(error.getSqlState())
+ # Neither the sub-class nor the main class declares a sqlState.
error = PySparkRuntimeError(
errorClass="SESSION_MUTATION_IN_DECLARATIVE_PIPELINE.SET_RUNTIME_CONF",
messageParameters={"method": "set"},
)
self.assertIsNone(error.getSqlState())
+ # A sub-class without its own sqlState inherits the main class's.
+ error = PySparkRuntimeError(
+ errorClass="NEAREST_BY_JOIN.UNSUPPORTED_MODE",
Review Comment:
You're right, it did not. `test_sqlstate_is_taken_from_the_main_class` pins
it now: the sub-class declares `08003` under a main class of `42604`, and the
lookup returns `42604`. With the override branch gone the sub-class entry is
never read, so it cannot rot.
--
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]