Skip to content

Conversation

@vrozov
Copy link
Member

@vrozov vrozov commented Nov 18, 2025

What changes were proposed in this pull request?

Drop view v in identifier-clause.sql

Why are the changes needed?

After #52765 view v is created and it is necessary to cleanup this view to avoid conflicts

Does this PR introduce any user-facing change?

No

How was this patch tested?

updated golden files and run the test

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

No

@github-actions github-actions bot added the SQL label Nov 18, 2025
@vrozov
Copy link
Member Author

vrozov commented Nov 18, 2025

@srielau and @cloud-fan Please review.

@vrozov
Copy link
Member Author

vrozov commented Nov 18, 2025

In my local environment ThriftServerQueryTestSuite was failing during describe.sql execution (failed to create view v) after identifier-clause.sql.

WITH identifier('v')(identifier('c1')) AS (VALUES(1)) (SELECT c1 FROM v);
CREATE OR REPLACE VIEW v(IDENTIFIER('c1')) AS VALUES(1);
SELECT c1 FROM v;
DROP VIEW v;
Copy link
Contributor

@cloud-fan cloud-fan Nov 19, 2025

Choose a reason for hiding this comment

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

Suggested change
DROP VIEW v;
DROP VIEW IF EXISTS v;

Copy link
Contributor

Choose a reason for hiding this comment

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

That's weird. Why could this be needed) There is something else hiding here. Unless the test files are executed in parallel. In that case we have a bigger problem.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh never mind.. The DROP VIEW was missing.

Copy link
Member Author

Choose a reason for hiding this comment

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

@cloud-fan I don't think that IF EXIST is preferred in this case

  • view is created just 2 lines above
  • if create view errors out, it is expected that select and drop would also error out
  • all drop view in this file do not use IF EXIST

Copy link
Contributor

Choose a reason for hiding this comment

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

My point is to not let DROP VIEW error out. It's just for cleanup the test resource, there is no point to test its error behavior.

Copy link
Member Author

Choose a reason for hiding this comment

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

It does not matter here if DROP VIEW v errors out or not. The goal is to cleanup and if the view does not exist (in the legacy case), both SELECT and DROP would error out consistently. The error does not affect anything.

Copy link
Contributor

Choose a reason for hiding this comment

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

The error gets committed into the golden file...

Copy link
Member Author

Choose a reason for hiding this comment

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

The same for SELECT one line above.

Copy link
Contributor

Choose a reason for hiding this comment

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

The cleanup code should be as less noisy as possible. Maybe we should have a clear separation between testing code and cleanup code in the golden file test framework, so that we don't commit anything for the cleanup code in the golden file. The SELECT one line above is clearly a testing code.

Thanks @dongjoon-hyun for quickly addressing this issue properly!

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-54412][TEST] Cleanup (drop) view created in identifier-clause.sql golden file [SPARK-54412][SQL][TEST] Cleanup (drop) view created in identifier-clause.sql golden file Nov 22, 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.

Thank you, @vrozov . It would be great if you can address @cloud-fan 's comment if you want to move forward.

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-54412][SQL][TEST] Cleanup (drop) view created in identifier-clause.sql golden file [SPARK-54412][SQL][TEST] Add DROP VIEW v; to identifier-clause* SQL golden files Nov 23, 2025
@dongjoon-hyun dongjoon-hyun changed the title [SPARK-54412][SQL][TEST] Add DROP VIEW v; to identifier-clause* SQL golden files [SPARK-54412][SQL][TEST] Clean up v properly in identifier-clause* SQL golden files Nov 23, 2025
@dongjoon-hyun dongjoon-hyun changed the title [SPARK-54412][SQL][TEST] Clean up v properly in identifier-clause* SQL golden files [SPARK-54412][SQL][TEST] Clean up v properly in identifier-clause.sql SQL golden file Nov 23, 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.

Hi, @vrozov , @cloud-fan , @srielau .

As a release manager, I made an alternative PR while keeping @vrozov 's authorship to unblock this PR's review process by showing @vrozov what was @cloud-fan 's review comment. Actually, it's @cloud-fan 's code in the review comment, but I respected @vrozov 's analysis and finding this bug.

dongjoon-hyun pushed a commit that referenced this pull request Nov 23, 2025
….sql` SQL golden file

### What changes were proposed in this pull request?

This PR aims to clean up `v` properly in `identifier-clause.sql` SQL golden file.

Note that this is originated from #53121 with the original authorship although the code is changed [according to the community review comment](#53121 (comment)).

### Why are the changes needed?

Due to the lack of a proper clean-up, this causes flaky test failures

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Pass the CIs.

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

No.

Closes #53121

Closes #53176 from dongjoon-hyun/SPARK-54412-2.

Authored-by: Vlad Rozov <vrozov@amazon.com>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
(cherry picked from commit 12bce6b)
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
@vrozov
Copy link
Member Author

vrozov commented Nov 24, 2025

Hi @dongjoon-hyun and @cloud-fan,

Please explain how this DROP VIEW v; is different from DROP VIEW test_view;? The later one causes the same error and it is (unnecessary) clean up code as well.

I think the error in the legacy case does not affect anything, and it is not obvious, is hard to maintain without extra comments or looking into .out files for "legacy" case, or knowing the history of why IF EXIST is there.

@cloud-fan
Copy link
Contributor

@vrozov I've explained the reasoning in #53121 (comment) , if you don't agree, we can discuss more but I don't think it worth the time. If you agree but you found some places not following it, feel free to fix them.

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.

4 participants