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-50744][SQL] Add a test case for view/CTE name resolution precedence #49378

Conversation

vladimirg-db
Copy link
Contributor

@vladimirg-db vladimirg-db commented Jan 6, 2025

What changes were proposed in this pull request?

Add an important test case for CTE resolution:

CREATE VIEW v1 AS SELECT 1;
CREATE VIEW v2 AS SELECT * FROM v1;

– The result is 1.
– The `v2` body will be inlined in the main query tree during the analysis, but upper `v1`
– CTE definition won't take precedence over the lower `v1` view.
WITH v1 AS (
  SELECT 2
)
SELECT * FROM v2;

This is an exception to the usual "CTE name takes precedence over the table/view name".

Why are the changes needed?

To harden Spark testing.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

New test case.

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

No.

@github-actions github-actions bot added the SQL label Jan 6, 2025
@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in b3182e5 Jan 7, 2025
Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

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

+1, LGTM. Thank you for adding this test case.

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.

3 participants