fix: route file-not-found errors through SparkError JSON path#3699
Open
andygrove wants to merge 10 commits intoapache:mainfrom
Open
fix: route file-not-found errors through SparkError JSON path#3699andygrove wants to merge 10 commits intoapache:mainfrom
andygrove wants to merge 10 commits intoapache:mainfrom
Conversation
Detect file-not-found errors from DataFusion's object store on the native side and convert them to SparkError::FileNotFound, which is serialized as JSON via CometQueryExecutionException. The shim layer then creates a proper SparkFileNotFoundException using QueryExecutionErrors.readCurrentFileNotFoundError(), producing the exact exception type that Spark tests expect. Previously, file-not-found errors arrived as CometNativeException and were pattern-matched in CometExecIterator to create a SparkException with a plain FileNotFoundException cause. Tests that cast the cause to SparkFileNotFoundException (which is private[spark]) would fail. Closes apache#3314
Remove the assume() skip for native_datafusion in FileBasedDataSourceSuite and the IgnoreCometNativeDataFusion tag in SimpleSQLViewSuite, since file-not-found errors now produce the correct SparkFileNotFoundException type.
Remove CometConf import from FileBasedDataSourceSuite and IgnoreCometNativeDataFusion import from SQLViewSuite that became unused after removing the test skips.
Extract file path from native error message and format it as "File <path> does not exist" to match the Hadoop FileNotFoundException message format that Spark tests expect.
readCurrentFileNotFoundError was removed in Spark 4.0. Construct SparkFileNotFoundException directly instead, which is accessible from the shim package.
….5.8 diff The SPARK-25207 test expects a specific error message for duplicate fields in case-insensitive mode, but native DataFusion produces a different schema error. Update the test to accept either message format.
…lds in 3.5.8 diff" This reverts commit 03328cd.
Add IgnoreCometNativeDataFusion tag to SPARK-25207 test instead of trying to accept both error messages. A separate PR will fix the underlying issue.
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.
Which issue does this PR close?
Closes #3314.
Rationale for this change
When
native_datafusionscan encounters missing files withignoreMissingFiles=false, it throws aCometNativeExceptionwith an error message like "Object at location ... not found".CometExecIteratorpattern-matches this message and wraps it in aSparkExceptionwith a plainFileNotFoundExceptioncause. However, Spark SQL tests expect the cause to beSparkFileNotFoundException(which isprivate[spark]), so the.asInstanceOf[SparkFileNotFoundException]cast fails.What changes are included in this PR?
FileNotFoundvariant toSparkErrorenum. Detect file-not-found errors inthrow_exception()(both theDataFusionError::Externalbranch and the generic catch-all) and convert them toSparkError::FileNotFound, which is serialized as JSON and thrown asCometQueryExecutionException."FileNotFound"case to all threeShimSparkErrorConverterimplementations (Spark 3.4, 3.5, 4.0) that callsQueryExecutionErrors.readCurrentFileNotFoundError(), producing a properSparkFileNotFoundException.fileNotFoundPatternregex matching from theCometNativeExceptionhandler since file-not-found errors are now handled through the JSON/shim path.How are these changes tested?
The fix enables the existing Spark SQL tests (
FileBasedDataSourceSuiteandSimpleSQLViewSuite) that were previously skipped fornative_datafusionto pass. The diff workarounds (assume()andIgnoreCometNativeDataFusiontags) can be removed in a follow-up once these tests are confirmed passing in CI.