-
Notifications
You must be signed in to change notification settings - Fork 28.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-50286][SQL] Correctly propagate SQL options to WriteBuilder
### What changes were proposed in this pull request? SPARK-49098 introduced a SQL syntax to allow users to set table options on DSv2 write cases, but unfortunately, the options set by SQL are not propagated correctly to the underlying DSv2 `WriteBuilder` ``` INSERT INTO $t1 WITH (`write.split-size` = 10) SELECT ... ``` ``` df.writeTo(t1).option("write.split-size", "10").append() ``` From the user's perspective, the above two are equivalent, but internal implementations differ slightly. Both of them are going to construct an ``` AppendData(r: DataSourceV2Relation, ..., writeOptions, ...) ``` but the SQL `options` are carried by `r.options`, and the `DataFrame` API `options` are carried by `writeOptions`. Currently, only the latter is propagated to the `WriteBuilder`, and the former is silently dropped. This PR fixes the above issue by merging those two `options`. Currently, the `options` propagation is inconsistent in `DataFrame`, `DataFrameV2`, and SQL: - DataFrame API, the same `options` are carried by both `writeOptions` and `DataSourceV2Relation` - DataFrameV2 API cases, options are only carried by `write options` - SQL, `options` are only carried by `DataSourceV2Relation` BTW, `SessionConfigSupport` only takes effect on `DataFrame` and `DataFrameV2` API, it is not considered in the `SQL` read/write path entirely in the current codebase. ### Why are the changes needed? Correctly propagate SQL options to `WriteBuilder`, to complete the feature added in SPARK-49098, so that DSv2 implementations like Iceberg can benefit. ### Does this PR introduce _any_ user-facing change? No, it's an unreleased feature. ### How was this patch tested? UTs added by SPARK-36680 and SPARK-49098 are updated also to check SQL `options` are correctly propagated to the physical plan ### Was this patch authored or co-authored using generative AI tooling? No. Closes #48822 from pan3793/SPARK-50286. Authored-by: Cheng Pan <[email protected]> Signed-off-by: Wenchen Fan <[email protected]>
- Loading branch information
Showing
9 changed files
with
406 additions
and
146 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.