Repository navigation
Conversation
… cause_idx in error details ### What changes were proposed in this pull request? `_extract_jvm_stacktrace` in `pyspark/errors/exceptions/connect.py` follows the `cause_idx` chain from `FetchErrorDetailsResponse` recursively, without validating the index. This PR walks the chain iteratively instead and stops when the next index is out of range or has already been visited, so each error is formatted at most once. The Scala client has a similar unguarded recursion in `GrpcExceptionConverter.errorsToThrowable`; this PR only covers the Python client. ### Why are the changes needed? If the error details returned by `FetchErrorDetails` contain a malformed cause chain, the client crashes inside error conversion and the original server error is lost: - a cyclic `cause_idx` (two errors pointing at each other, or an error listed as its own cause) raises `RecursionError: maximum recursion depth exceeded` - an out-of-range `cause_idx` raises `IndexError: list index out of range` Reproducible by calling `convert_exception` with a `FetchErrorDetailsResponse` where `errors[0].cause_idx = 1` and `errors[1].cause_idx = 0`. ### Does this PR introduce _any_ user-facing change? Only for malformed error details: the client now raises the converted server exception instead of `RecursionError`/`IndexError`. Well-formed cause chains are formatted exactly as before. ### How was this patch tested? Added `test_convert_exception_with_malformed_cause_chain` to `pyspark.errors.tests.test_connect_errors_conversion` covering the mutual cycle, the self-cycle, and the out-of-range case. All tests in the module pass: ``` python -m pytest python/pyspark/errors/tests/test_connect_errors_conversion.py 13 passed ``` ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code Closes apache#58515 from Eliaaazzz/SPARK-59119. Authored-by: Elia Liu <Elialiu760317@outlook.com> Signed-off-by: Holden Karau <holden.karau@snowflake.com> (cherry picked from commit 581c83b) Signed-off-by: Holden Karau <holden.karau@snowflake.com>
holdenk
force-pushed
the
backport-pr58515-branch-4.4
branch
from
November 25, 2026 05:12
c4dabae to
474d636
Compare
…rmExpressionSuite Add IntBucketFunction and ProduceResultBucketFunction to TransformExpressionSuite. The SPARK-62319 backport uses them, but they come from SPARK-60541, which is not on branch-4.4, so catalyst test compilation fails. Co-authored-by: Isaac <no-reply@databricks.com> (cherry picked from commit b112919) NOTE: TEMPORARY cherry-pick of apache#60865 (not part of this backport) so CI can compile TransformExpressionSuite on this branch. Once that fix is merged into the release branch this commit drops out on rebase; do not merge it as part of this PR.
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.
Backport of #58515 to
branch-4.4, cherry-picked from 581c83b.Opened by
dev/merge_spark_pr.py. Merging this PR with the script commits its first commit's message, which keeps #58515's message, footer and author, and addsBackport-PRwith this PR's number and the merger's sign-off. Fixups go in as further commits; their authors getCo-authored-by.