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-46144][SQL] Fail INSERT INTO ... REPLACE statement if the condition contains subquery #44060

Closed
wants to merge 7 commits into from

Conversation

gengliangwang
Copy link
Member

What changes were proposed in this pull request?

For the following query:

INSERT INTO tbl REPLACE WHERE id = (select c2 from values(1) as t(c2)) SELECT * FROM source

There will be an analysis error:

[UNRESOLVED_COLUMN.WITHOUT_SUGGESTION] A column, variable, or function parameter with name `c2` cannot be resolved.  SQLSTATE: 42703; line 1 pos 51;
'OverwriteByExpression RelationV2[id#27L, data#28] testcat.tbl testcat.tbl, (id#27L = scalar-subquery#26 []), false 

The error message is confusing. The actual reason is the OverwriteByExpression plan doesn't support subqueries. While supporting the feature is non-trivial, this PR is to improve the error message as

[UNSUPPORTED_FEATURE.OVERWRITE_BY_SUBQUERY] The feature is not supported: INSERT OVERWRITE with a subquery condition. SQLSTATE: 0A000; line 1 pos 43;

Why are the changes needed?

Error message improvement

Does this PR introduce any user-facing change?

No

How was this patch tested?

New UT

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

No

@gengliangwang
Copy link
Member Author

cc @srielau as well

@github-actions github-actions bot added the DOCS label Nov 29, 2023
Copy link
Contributor

@beliefer beliefer left a comment

Choose a reason for hiding this comment

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

LGTM. cc @MaxGekk

@gengliangwang
Copy link
Member Author

@HyukjinKwon @beliefer Thanks for the review, merging to master

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