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.

huangxiaopingRD pushed a commit to huangxiaopingRD/spark that referenced this pull request Nov 25, 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 apache#53121 with the original authorship although the code is changed [according to the community review comment](apache#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 apache#53121

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

Authored-by: Vlad Rozov <vrozov@amazon.com>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
@vrozov
Copy link
Member Author

vrozov commented Nov 25, 2025

@cloud-fan I don't agree with your reasoning, as I already mentioned several times in my comments: #53121 (comment), #53121 (comment). Somehow, it was important for you to discuss this change, and

does not matter.

Consider identifier-clause.sql (not a legacy case). Will you use IF EXIST for the view that is created in the same script?

Anyway, if it is important for you and the community to have less "noise", I would expect other similar cases where a table or view fails to be created and then dropped to be updated to use IF EXIST at least to be consistent and avoid confusion from other committers.

@cloud-fan
Copy link
Contributor

Will you use IF EXIST for the view that is created in the same script?

Yes if the view is not guaranteed to be created. @vrozov we need to understand that reality does not always match our expectation. You are right about the reality, but what I said before is about expectation. I'll be surprised if you don't agree with the expectation (less noise), and if you agree, you are welcome to improve the reality to better match the expectation.

@vrozov
Copy link
Member Author

vrozov commented Dec 2, 2025

@cloud-fan

Yes if the view is not guaranteed to be created.

In the case of identifier-clause.sql, the view is guaranteed to be created. If it is not created, the test would fail.

I'll be surprised if you don't agree with the expectation

Expectations are

  1. View is created, select succeeds, and drop succeeds in case of identifier-clause.sql
  2. View is not created, select fails, and drop fails in case of identifier-clause-legacy.sql
  3. Optionally, you can use IF EXIST clause, but in that case, it should be consistent across all usages of DROP clause.

I do agree that "less noise" is preferred (for example large number of warnings during compilation), but I don't agree that it applies here. Errors and warnings are not always "noise". Golden files are designed to handle both positive and negative cases, and in the case of identifier-clause-legacy.sql, it is simply the negative case, not "noise".

@cloud-fan
Copy link
Contributor

the view is guaranteed to be created

This is not correct. The same golden file can be tested with different setups, so the view may not be created if legacy IDENTIFY is enabled.

@vrozov
Copy link
Member Author

vrozov commented Dec 3, 2025

Assume for a second that the legacy case does not exist. Consider a case where someone creates a brand new file that creates a view, selects from the view, and drops the view. Will you use IF EXIST in that case? After some time, another developer may use that file in a different setup where the create view fails. Will you ask that developer to change the first file?

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