[WIP][SPARK-56171][SQL] Enable file source V2 write path with partition, dynamic overwrite, and catalog table support#54981
Closed
LuciferYang wants to merge 1 commit intoapache:masterfrom
Closed
Conversation
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?
This PR enables the file source V2 write path (
FileWrite) to support partition columns, dynamic partition overwrite, and truncate (full overwrite), gated behind a new feature flagspark.sql.sources.v2.file.write.enabled(defaultfalse). It also removes the guard that blockedFileDataSourceV2from working with catalog tables.Previously, the V2 file write path was completely disabled —
DataFrameWriterreturnedNoneforFileDataSourceV2,FallBackFileSourceV2converted allInsertIntoStatementtargetingFileTableback to the V1 path, andDataSourceV2Utils.getTableProviderunconditionally filtered outFileDataSourceV2for catalog tables. TheFileWrite.createWriteJobDescriptionhardcodedpartitionColumns = Seq.emptyanddataColumns = allColumns, meaning partitioned writes were impossible even if the V2 path was reached.Why are the changes needed?
The file source V2 write path has been disabled since SPARK-28396 with a
TODOcomment. This blocks V2 from being the default for built-in file formats. The V2 API offers advantages over V1 (custom metrics, aggregate/limit/join pushdown, runtime filtering, row-level operations), but the write path must work before V2 can replace V1.This is the first patch in a series to close the V1-V2 feature gap. It establishes the write infrastructure behind a feature flag so that subsequent patches can build on it incrementally: cache invalidation, flag flip, and delete FallBackFileSourceV2 (SPARK-56173), ErrorIfExists/Ignore modes (SPARK-56174), partition management (SPARK-56175), statistics (SPARK-56176), bucketing (SPARK-56177), and MSCK REPAIR TABLE (SPARK-56178).
Does this PR introduce any user-facing change?
No. The feature flag
spark.sql.sources.v2.file.write.enableddefaults tofalse. All existing behavior is unchanged. When explicitly enabled, the V2 write path is used forAppendandOverwritemodes via the DataFrame API, and catalog tables using file-based formats are loaded as V2FileTableinstances.How was this patch tested?
Added 13 new tests in
FileDataSourceV2FallBackSuiteWas this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code 4.6.