[SPARK-56022][SQL] Preserve SparkThrowable error classes in parmap/awaitResult#54846
Open
linhongliu-db wants to merge 1 commit intoapache:masterfrom
Open
[SPARK-56022][SQL] Preserve SparkThrowable error classes in parmap/awaitResult#54846linhongliu-db wants to merge 1 commit intoapache:masterfrom
linhongliu-db wants to merge 1 commit intoapache:masterfrom
Conversation
…aitResult `SparkException` at `ParquetFileFormat$.readParquetFootersInParallel` already has the structured error class `FAILED_READ_FILE.CANNOT_READ_FILE_FOOTER` with SQL state `KD001`, but `SparkThreadUtils.awaitResult` wraps it in a generic `SparkException`, hiding the SQL state. This PR: 1. **Adds `preserveSparkThrowable` parameter** to `SparkThreadUtils.awaitResult`, `ThreadUtils.awaitResult`, and `ThreadUtils.parmap` (default `false` — no behavior change for existing callers) 2. **Updates `ParquetFileFormat.readParquetFootersInParallel`** to pass `preserveSparkThrowable = true` to `parmap`, preserving the structured error class When reading parquet footers in parallel, the `FAILED_READ_FILE.CANNOT_READ_FILE_FOOTER` error class is wrapped in a generic `SparkException` by `awaitResult`, losing the structured SQL state. This makes it harder for users and applications to programmatically handle specific error conditions. Yes. `ParquetFileFormat.readParquetFootersInParallel` now throws the structured `SparkException` directly instead of wrapping it in a generic `SparkException`. The error class and SQL state are preserved. 1. Added unit tests in `ThreadUtilsSuite` for `awaitResult` (Awaitable and JFuture) and `parmap` with `preserveSparkThrowable` flag true/false 2. Updated `ParquetFileFormatSuite` to verify the error class is thrown directly Yes. Co-authored-by: Isaac
9df65fd to
b754861
Compare
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.
What changes were proposed in this pull request?
SparkExceptionatParquetFileFormat$.readParquetFootersInParallelalready has the structured error classFAILED_READ_FILE.CANNOT_READ_FILE_FOOTERwith SQL stateKD001, butSparkThreadUtils.awaitResultwraps it in a genericSparkException, hiding the SQL state.This PR:
preserveSparkThrowableparameter toSparkThreadUtils.awaitResult,ThreadUtils.awaitResult, andThreadUtils.parmap(defaultfalse— no behavior change for existing callers)ParquetFileFormat.readParquetFootersInParallelto passpreserveSparkThrowable = truetoparmap, preserving the structured error classFiles changed:
SparkThreadUtils.scala— new 3-paramawaitResultoverloadThreadUtils.scala— new 3-paramawaitResultoverloads (Awaitable + JFuture) +parmapflagParquetFileFormat.scala— caller passespreserveSparkThrowable = truetoparmapThreadUtilsSuite.scala— tests forawaitResultandparmappreservationParquetFileFormatSuite.scala— updated test to verify error class is thrown directlyWhy are the changes needed?
When reading parquet footers in parallel, the
FAILED_READ_FILE.CANNOT_READ_FILE_FOOTERerror class is wrapped in a genericSparkExceptionbyawaitResult, losing the structured SQL state. This makes it harder for users and applications to programmatically handle specific error conditions.Does this PR introduce any user-facing change?
Yes.
ParquetFileFormat.readParquetFootersInParallelnow throws the structuredSparkExceptiondirectly instead of wrapping it in a genericSparkException. The error class and SQL state are preserved.How was this patch tested?
ThreadUtilsSuiteforawaitResult(Awaitable and JFuture) andparmapwithpreserveSparkThrowableflag true/falseParquetFileFormatSuiteto verify the error class is thrown directlyWas this patch authored or co-authored using generative AI tooling?
Yes.