Skip to content

Conversation

@grundprinzip
Copy link
Contributor

What changes were proposed in this pull request?

This patch optimizes the handling of errors reported back to Python. First, it properly allows the extraction of the ERROR_CLASS and the SQL_STATE and gives simpler accces to the stack trace.

It therefore makes sure that the display of the stack trace is no longer only server-side decided but becomes a local usability property.

In addition the following methods on the SparkConnectGrpcException become actually useful:

  • getSqlState()
  • getErrorClass()
  • getStackTrace()

Why are the changes needed?

Compatibility

Does this PR introduce any user-facing change?

No

How was this patch tested?

Updated the existing tests.

Was this patch authored or co-authored using generative AI tooling?

No

Copy link
Contributor

@juliuszsompolski juliuszsompolski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with nits

Copy link
Member

@HyukjinKwon HyukjinKwon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amazing, LGTM

@itholic mind double checking?

@HyukjinKwon
Copy link
Member

Oh let's also file a JIRA btw

@grundprinzip grundprinzip changed the title [SPARK-XXX][CONNECT][PYTHON] Better error handling for SQL Exceptions [SPARK-45808][CONNECT][PYTHON] Better error handling for SQL Exceptions Nov 6, 2023
@grundprinzip
Copy link
Contributor Author

Filed SPARK-45808

ErrorUtils.throwableToFetchErrorDetailsResponse(
st = error,
serverStackTraceEnabled = sessionHolder.session.conf.get(
Connect.CONNECT_SERVER_STACKTRACE_ENABLED) || sessionHolder.session.conf.get(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we deprecating this config Connect.CONNECT_SERVER_STACKTRACE_ENABLED?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still used, but only verifies the display behavior rather than the stack trace generation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also make Connect.CONNECT_SERVER_STACKTRACE_ENABLED work for Scala client in this pr?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit more weird, in contrast to Python, the server backtrace is always there in Scala, but the user can decide how to print it.

@HyukjinKwon
Copy link
Member

Merged to master.

@itholic
Copy link
Contributor

itholic commented Nov 7, 2023

Late LGTM. This is cool. Thanks!

HyukjinKwon pushed a commit that referenced this pull request Dec 19, 2023
### What changes were proposed in this pull request?

Revert #44144, and introduce a forbid recursion guard as previously proposed. This way the infinite error handling recursion is still prevented, but the client-side knob is still present.

### Why are the changes needed?

Previously proposed as part of #44144, however was discussed in favour of something else. However it seems (proposal by grundprinzip) that the original proposal was more correct, since it seems driver stacktrace is decided on client not server (see #43667)

### Does this PR introduce _any_ user-facing change?

No

### How was this patch tested?

Hand testing

### Was this patch authored or co-authored using generative AI tooling?
No

Closes #44210 from cdkrot/forbid_recursive_error_handling_2.

Authored-by: Alice Sayutina <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants