[SPARK-43390][SQL] DSv2 allows CTAS/RTAS to reserve schema nullability#41070
Closed
pan3793 wants to merge 3 commits into
Closed
[SPARK-43390][SQL] DSv2 allows CTAS/RTAS to reserve schema nullability#41070pan3793 wants to merge 3 commits into
pan3793 wants to merge 3 commits into
Conversation
This was referenced May 5, 2023
Member
Author
cloud-fan
reviewed
May 8, 2023
| * Return whether to reserve schema nullability of query output or forcibly use nullable schema | ||
| * on creating table implicitly, e.g. CTAS/RTAS. | ||
| */ | ||
| default boolean createTableReserveSchemaNullability() { |
Contributor
There was a problem hiding this comment.
how about
/**
* If true, mark all the fields of the query schema as nullable when executing
* CREATE/REPLACE TABLE ... AS SELECT ... and creating the table.
*/
default boolean useNullableQuerySchema
beliefer
reviewed
May 8, 2023
| } | ||
| } | ||
|
|
||
| class TestCreateTableReserveSchemaNullabilityCatalog extends InMemoryCatalog { |
Contributor
There was a problem hiding this comment.
How about ForbidSchemaNullabilityCatalog ?
Member
Author
There was a problem hiding this comment.
"forbid" seems not accurate here, would prefer to use "reserve" to represent respecting the query schema nullability
Contributor
There was a problem hiding this comment.
I means the name seems too long. Could you rename it with simple one ?
Member
Author
There was a problem hiding this comment.
Maybe "ReserveSchemaNullabilityCatalog"?
Member
Author
There was a problem hiding this comment.
changed to "ReserveSchemaNullabilityCatalog"
cloud-fan
approved these changes
May 8, 2023
cloud-fan
approved these changes
May 8, 2023
cloud-fan
approved these changes
May 8, 2023
cloud-fan
approved these changes
May 8, 2023
beliefer
approved these changes
May 9, 2023
Contributor
|
thanks, merging to master! |
LuciferYang
pushed a commit
to LuciferYang/spark
that referenced
this pull request
May 10, 2023
### What changes were proposed in this pull request? Add a new method `useNullableQuerySchema` in `Table`, to allow the DataSource implementation to declare whether they need to reserve schema nullability on CTAS/RTAS. ### Why are the changes needed? SPARK-28837 forcibly uses the nullable schema on CTAS/RTAS, which seems too aggressive: 1. The existing matured RDBMSs have different behaviors for reserving schema nullability on CTAS/RTAS, as mentioned in apache#25536, PostgreSQL forcibly uses the nullable schema, but MySQL respects the query's output schema nullability. 2. Some OLAP systems(e.g. ClickHouse) are perf-sensitive for nullable, and have strict restrictions on table schema, e.g. the primary keys are not allowed to be nullable. ### Does this PR introduce _any_ user-facing change? Yes, this PR adds a new DSv2 API, but the default implementation reserves backward compatibility. ### How was this patch tested? UTs are updated. Closes apache#41070 from pan3793/SPARK-43390. Authored-by: Cheng Pan <chengpan@apache.org> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
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 new method
useNullableQuerySchemainTableCatalog, to allow the DataSource implementation to declare whether they need to reserve schema nullability on CTAS/RTAS.Why are the changes needed?
SPARK-28837 forcibly uses the nullable schema on CTAS/RTAS, which seems too aggressive:
Does this PR introduce any user-facing change?
Yes, this PR adds a new DSv2 API, but the default implementation reserves backward compatibility.
How was this patch tested?
UTs are updated.