Repository navigation
fix(thrift): forward server SQLSTATE on failed operations - #1083
Open
atharva18-hue wants to merge 1 commit into
Open
atharva18-hue wants to merge 1 commit into
atharva18-hue wants to merge 1 commit into
Conversation
The Thrift backend dropped the failed operation's server-reported SQLSTATE: _check_command_not_in_error_or_closed_state raised ServerOperationError without the payload's sqlState, while the kernel backend sets sql_state on the same exception class. Attach the operation-level sqlState to the raised exception in both the displayMessage and errorMessage paths; None when the payload carries none (never invent one). Fixes databricks#1012 Signed-off-by: Atharva Chavhan <atharvachavhan18@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1012
Problem
On the Thrift backend, when a statement compiles and then fails at runtime on the server,
_check_command_not_in_error_or_closed_stateraisesServerOperationErrorfrom the terminal operation-status payload but never forwards that payload's top-levelsqlState, so the error exposes nosql_state. The kernel backend sets that exact attribute on the same exception class, so SQLSTATE availability depended on which wire protocol delivered the failure.Change
Attach the operation-level
sqlStateto the raisedServerOperationErrorin both thedisplayMessageanderrorMessagepaths, mirroring the kernel backend's attribute forwarding. When the payload carries no SQLSTATE,sql_stateisNone— never invented. The envelopestatus.sqlStateis not used.Tests
test_get_status_forwards_server_sql_stateandtest_get_status_sql_state_is_none_when_server_sends_noneintests/unit/test_thrift_backend.py, mirroring the existingtest_get_status_uses_display_message_if_available._check_command_not_in_error_or_closed_statewith an ERROR_STATE payload carryingsqlState='42000'raisesServerOperationErrorwithsql_state == '42000'on both paths, andsql_state is Nonewhen the payload carries none.pytest tests/unit/test_thrift_backend.py: 99 passed, 84 skipped. The skips are the pyarrow-gated tests (this class is skipped when pyarrow cannot import); in my environment pyarrow requires NumPy >= 2.0 while only 1.26.4 is available, so the two new tests were skipped here and need CI to run them.test_failed_operation_error_exposes_server_sql_statein databricks-driver-test) needs a live Databricks workspace, which I don't have.