dongjoon-hyun opened a new pull request, #479:
URL: https://github.com/apache/spark-connect-swift/pull/479
### What changes were proposed in this pull request?
This PR improves `SparkConnectError` to carry the server-side error chain by
calling the
`FetchErrorDetails` RPC, like the PySpark (`_fetch_enriched_error`) and Scala
(`GrpcExceptionConverter.fetchEnrichedError`) clients.
1. A new `SparkConnectError.ServerError` struct carries the un-truncated
error message, the
exception class hierarchy, the server-side stack trace frames, and the
per-error
`errorClass`/`sqlState`/`messageParameters`. `SparkConnectError.Details`
gains a `serverErrors`
array (the thrown error first, followed by the cause chain flattened via
`causeIdx`) and a
`serverStackTrace` convenience property that renders the chain in the JVM
`Caused by:`/`at ...` style.
2. When the `google.rpc.ErrorInfo` metadata contains an `errorId`,
`GrpcErrorConverter` sends one
`FetchErrorDetails` request over the already-open gRPC connection. The
call is best-effort
at-most-once without retries, and any failure silently falls back to the
previous
`ErrorInfo`-only conversion so that the original error is never masked.
3. The `errorClass` and `sqlState` from `ErrorInfo` take precedence to keep
the error
classification stable, while the truncated `message` and
`messageParameters` are replaced by
the un-truncated values of the root error.
The server-side stack trace is populated only when the SQL configuration
`spark.sql.connect.serverStacktrace.enabled` is true, like the other clients.
```swift
} catch SparkConnectError.tableOrViewNotFound(let details) {
print(details.serverErrors.first?.errorTypeHierarchy ?? [])
// ["org.apache.spark.sql.catalyst.ExtendedAnalysisException",
// "org.apache.spark.sql.AnalysisException", ...]
print(details.serverStackTrace ?? "")
}
```
### Why are the changes needed?
Users could not access the server-side stack trace, the cause chain, or the
un-truncated error
message from a caught error although the server provides them via the
`FetchErrorDetails` RPC.
### Does this PR introduce _any_ user-facing change?
Yes, `SparkConnectError` additionally provides the server-side error chain.
The existing code
continues to compile and behave the same because the new
`Details.serverErrors` field has a
default value and the error classification is unchanged.
### How was this patch tested?
Pass the CIs with the newly added `serverErrors` and `serverStackTrace`
tests in
`SparkConnectErrorTests`. All existing test suites pass unmodified.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Fable 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]