[SPARK-56459][SQL] Fix MatchError in FileDataSourceV2.attachFilePath for fatal errors#55324
Open
yaooqinn wants to merge 2 commits intoapache:masterfrom
Open
[SPARK-56459][SQL] Fix MatchError in FileDataSourceV2.attachFilePath for fatal errors#55324yaooqinn wants to merge 2 commits intoapache:masterfrom
yaooqinn wants to merge 2 commits intoapache:masterfrom
Conversation
| throw QueryExecutionErrors.fileNotExistError(filePath, e) | ||
| case NonFatal(e) => | ||
| throw QueryExecutionErrors.cannotReadFilesError(e, filePath) | ||
| case other => throw other |
Member
There was a problem hiding this comment.
Can we have a unit test case for this, @yaooqinn ?
How was this patch tested?
Observed the MatchError during TPC-DS SF100 benchmark with large Parquet row groups on executors with constrained heap memory.
dongjoon-hyun
approved these changes
Apr 13, 2026
Member
dongjoon-hyun
left a comment
There was a problem hiding this comment.
+1 for the code itself.
…for fatal errors attachFilePath uses NonFatal pattern matching which does not match fatal errors like OutOfMemoryError. When OOM occurs during file reading, the incomplete match causes a MatchError that masks the original error. Add a catch-all case to rethrow fatal errors directly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…lePath Add comprehensive unit tests for all branches of FileDataSourceV2.attachFilePath: - SparkUpgradeException is rethrown directly - FAILED_READ_FILE.CANNOT_READ_FILE_FOOTER is rethrown directly - SchemaColumnConvertNotSupportedException is wrapped - FileNotFoundException is wrapped - NonFatal exceptions are wrapped - Fatal errors (OutOfMemoryError, StackOverflowError) are rethrown directly Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| assert(thrown.getCause eq cause) | ||
| } | ||
|
|
||
| test("SPARK-56459: attachFilePath rethrows fatal errors directly") { |
Member
There was a problem hiding this comment.
Thank you for adding this.
| assert(thrown eq oom) | ||
| } | ||
|
|
||
| test("SPARK-56459: attachFilePath rethrows StackOverflowError directly") { |
Member
There was a problem hiding this comment.
Thank you for adding this, too.
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?
Add a catch-all case in
FileDataSourceV2.attachFilePathto rethrow fatal errors (likeOutOfMemoryError) directly instead of letting them cause aMatchError.Why are the changes needed?
attachFilePathusesNonFatalpattern matching which does not match fatal errors likeOutOfMemoryError. Callers catchThrowableand pass it to this method:When OOM occurs during file reading (e.g., large Parquet row groups), the incomplete match causes a
scala.MatchErrorthat masks the original error:Does this PR introduce any user-facing change?
Yes. Previously, users would see a confusing
MatchErrorwhen OOM occurred during file reading. Now they see the originalOutOfMemoryError.How was this patch tested?
Observed the MatchError during TPC-DS SF100 benchmark with large Parquet row groups on executors with constrained heap memory.
Was this patch authored or co-authored using generative AI tooling?
Yes, co-authored using GitHub Copilot CLI (Claude Opus 4.6).