Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-49975][SQL] Disallow LEGACY storeAssignmentPolicy with DataFrameWriterV2 API #48476

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

manuzhang
Copy link
Contributor

What changes were proposed in this pull request?

Before this PR, store assignment policy is validated for V2Write command when v2Write.table.resolved && v2Write.query.resolved && !v2Write.outputResolved is true. However, !v2Write.outputResolved doesn't hold for DataFrameWriterV2 API and the policy is not validated. This PR validates store assignment policy for V2Write command without any conditions.

Why are the changes needed?

LEGACY store assignment policy should not be allowed writing to v2 table with DataFrameWriterV2 API.

Does this PR introduce any user-facing change?

An AnalysisError will be thrown when users write to v2 table with DataFrameWriterV2 API and spark.sql.storeAssignmentPolicy=LEGACY

How was this patch tested?

UT.

Was this patch authored or co-authored using generative AI tooling?

No.

@github-actions github-actions bot added the SQL label Oct 15, 2024
@manuzhang
Copy link
Contributor Author

@cloud-fan @yaooqinn @wangyum The following is allowed with legacy store assignment policy after #47082

CREATE TABLE testcat.ns.t1 (d1 string, d2 varchar(200)) USING parquet;
CREATE TABLE testcat.ns.t2 USING foo as select * from testcat.ns.t1;

I'm wondering to what extent is the policy allowed in data source v2.

checkError(
exception = intercept[AnalysisException] {
spark.range(10)
.writeTo("table_name")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what was the behavior before? Do we add hard cast for the input query?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants