-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-43203][SQL] Move all Drop Table case to DataSource V2 #41348
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
Conversation
39268a4 to
bfd7c2f
Compare
sql/catalyst/src/main/java/org/apache/spark/sql/connector/catalog/IdentifierImpl.java
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala
Outdated
Show resolved
Hide resolved
| isSameName(ident.qualifier :+ ident.name) && | ||
| isSameName(v1Ident.catalog.toSeq ++ v1Ident.database :+ v1Ident.table) | ||
|
|
||
| case SubqueryAlias(ident, HiveTableRelation(catalogTable, _, _, _, _)) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add support for HiveTableRelation in isMatchedTableOrView, so that can remove Cache normally when use hive catalog.
| try { | ||
| V1Table(catalog.getTableMetadata(ident.asTableIdentifier)) | ||
| } catch { | ||
| case _: NoSuchDatabaseException => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loadTable will return NoSuchDatabaseException, not same as v1 behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it cause test failures?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the DerbyTableCatalogSuite:SPARK-42978: RENAME cannot qualify a new-table-Name with a schema-Name. will failed without this change.
sql/core/src/test/scala/org/apache/spark/sql/execution/command/PlanResolutionSuite.scala
Outdated
Show resolved
Hide resolved
sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala
Show resolved
Hide resolved
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala
Outdated
Show resolved
Hide resolved
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/V2SessionCatalog.scala
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/internal/connector/IdentifierImpl.scala
Outdated
Show resolved
Hide resolved
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/V2SessionCatalog.scala
Outdated
Show resolved
Hide resolved
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/command/DropTableSuite.scala
Show resolved
Hide resolved
|
Is the test failure related? |
sql/catalyst/src/main/java/org/apache/spark/sql/connector/catalog/IdentifierImpl.java
Outdated
Show resolved
Hide resolved
I think not, many PR can't pass sql - other tests at now. Seem ci have something wrong. |
Done, please wait. |
|
@cloud-fan @viirya Hi folks, the CI passed. Can we move forward next step? |
|
thanks, merging to master! |
|
Thanks @cloud-fan @viirya |
|
I unfortunately created this initially as improvement. It is actually a bug and regression, which breaks DROP in custom sessions catalogs. Can we include it in 3.4.2? |
|
I'm okay with changing it to bug and backport to 3.4.2. cc @cloud-fan |
<!-- Thanks for sending a pull request! Here are some tips for you: 1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html 2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html 3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'. 4. Be sure to keep the PR description updated to reflect all changes. 5. Please write your PR title to summarize what this PR proposes. 6. If possible, provide a concise example to reproduce the issue for a faster review. 7. If you want to add a new configuration, please read the guideline first for naming configurations in 'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'. 8. If you want to add or modify an error type or message, please read the guideline first in 'core/src/main/resources/error/README.md'. --> ### What changes were proposed in this pull request? In order to fix DROP table behavior in session catalog cause by apache#37879. Because we always invoke V1 drop logic if the identifier looks like a V1 identifier. This is a big blocker for external data sources that provide custom session catalogs. So this PR move all Drop Table case to DataSource V2 (use drop table to drop view not include). More information please check https://github.com/apache/spark/pull/37879/files#r1170501180 <!-- Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below. 1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers. 3. If you fix some SQL features, you can provide some references of other DBMSes. 4. If there is design documentation, please add the link. 5. If there is a discussion in the mailing list, please add the link. --> ### Why are the changes needed? Move Drop Table case to DataSource V2 to fix bug and prepare for remove drop table v1. <!-- Please clarify why the changes are needed. For instance, 1. If you propose a new API, clarify the use case for a new API. 2. If you fix a bug, you can clarify why it is a bug. --> ### Does this PR introduce _any_ user-facing change? No <!-- Note that it means *any* user-facing change including all aspects such as the documentation fix. If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible. If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master. If no, write 'No'. --> ### How was this patch tested? Tested by: - V2 table catalog tests: `org.apache.spark.sql.execution.command.v2.DropTableSuite` - V1 table catalog tests: `org.apache.spark.sql.execution.command.v1.DropTableSuiteBase` <!-- If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible. If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future. If tests were not added, please describe why they were not added and/or why it was difficult to add. If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks. --> Closes apache#41348 from Hisoka-X/SPARK-43203_drop_table_to_v2. Authored-by: Jia Fan <[email protected]> Signed-off-by: Wenchen Fan <[email protected]> (cherry picked from commit 32a5db4)
… null table ### What changes were proposed in this pull request? This is a followup of #41348 . Previously `V2SessionCatalog.dropTable` treated null table as table not exists, but #41348 broke it. This PR fixes it. ### Why are the changes needed? to keep old behavior. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? existing tests Closes #42056 from cloud-fan/mm. Authored-by: Wenchen Fan <[email protected]> Signed-off-by: Kent Yao <[email protected]>
… null table ### What changes were proposed in this pull request? This is a followup of #41348 . Previously `V2SessionCatalog.dropTable` treated null table as table not exists, but #41348 broke it. This PR fixes it. ### Why are the changes needed? to keep old behavior. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? existing tests Closes #42056 from cloud-fan/mm. Authored-by: Wenchen Fan <[email protected]> Signed-off-by: Kent Yao <[email protected]> (cherry picked from commit 704131b) Signed-off-by: Kent Yao <[email protected]>
… null table ### What changes were proposed in this pull request? This is a followup of apache#41348 . Previously `V2SessionCatalog.dropTable` treated null table as table not exists, but apache#41348 broke it. This PR fixes it. ### Why are the changes needed? to keep old behavior. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? existing tests Closes apache#42056 from cloud-fan/mm. Authored-by: Wenchen Fan <[email protected]> Signed-off-by: Kent Yao <[email protected]> (cherry picked from commit 704131b)
<!-- Thanks for sending a pull request! Here are some tips for you: 1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html 2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html 3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'. 4. Be sure to keep the PR description updated to reflect all changes. 5. Please write your PR title to summarize what this PR proposes. 6. If possible, provide a concise example to reproduce the issue for a faster review. 7. If you want to add a new configuration, please read the guideline first for naming configurations in 'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'. 8. If you want to add or modify an error type or message, please read the guideline first in 'core/src/main/resources/error/README.md'. --> ### What changes were proposed in this pull request? In order to fix DROP table behavior in session catalog cause by apache#37879. Because we always invoke V1 drop logic if the identifier looks like a V1 identifier. This is a big blocker for external data sources that provide custom session catalogs. So this PR move all Drop Table case to DataSource V2 (use drop table to drop view not include). More information please check https://github.com/apache/spark/pull/37879/files#r1170501180 <!-- Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below. 1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers. 3. If you fix some SQL features, you can provide some references of other DBMSes. 4. If there is design documentation, please add the link. 5. If there is a discussion in the mailing list, please add the link. --> ### Why are the changes needed? Move Drop Table case to DataSource V2 to fix bug and prepare for remove drop table v1. <!-- Please clarify why the changes are needed. For instance, 1. If you propose a new API, clarify the use case for a new API. 2. If you fix a bug, you can clarify why it is a bug. --> ### Does this PR introduce _any_ user-facing change? No <!-- Note that it means *any* user-facing change including all aspects such as the documentation fix. If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible. If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master. If no, write 'No'. --> ### How was this patch tested? Tested by: - V2 table catalog tests: `org.apache.spark.sql.execution.command.v2.DropTableSuite` - V1 table catalog tests: `org.apache.spark.sql.execution.command.v1.DropTableSuiteBase` <!-- If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible. If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future. If tests were not added, please describe why they were not added and/or why it was difficult to add. If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks. --> Closes apache#41348 from Hisoka-X/SPARK-43203_drop_table_to_v2. Authored-by: Jia Fan <[email protected]> Signed-off-by: Wenchen Fan <[email protected]> (cherry picked from commit 32a5db4)
… null table ### What changes were proposed in this pull request? This is a followup of apache#41348 . Previously `V2SessionCatalog.dropTable` treated null table as table not exists, but apache#41348 broke it. This PR fixes it. ### Why are the changes needed? to keep old behavior. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? existing tests Closes apache#42056 from cloud-fan/mm. Authored-by: Wenchen Fan <[email protected]> Signed-off-by: Kent Yao <[email protected]> (cherry picked from commit 704131b)
### What changes were proposed in this pull request? cherry pick #41348 and #42056 , this a bug fixed should be included in 3.4.2 ### Why are the changes needed? Fix DROP table behavior in session catalog ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Tested by: - V2 table catalog tests: `org.apache.spark.sql.execution.command.v2.DropTableSuite` - V1 table catalog tests: `org.apache.spark.sql.execution.command.v1.DropTableSuiteBase` Closes #41765 from Hisoka-X/move_drop_table_v2_to_3.4.2. Lead-authored-by: Jia Fan <[email protected]> Co-authored-by: Wenchen Fan <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
<!-- Thanks for sending a pull request! Here are some tips for you: 1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html 2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html 3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'. 4. Be sure to keep the PR description updated to reflect all changes. 5. Please write your PR title to summarize what this PR proposes. 6. If possible, provide a concise example to reproduce the issue for a faster review. 7. If you want to add a new configuration, please read the guideline first for naming configurations in 'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'. 8. If you want to add or modify an error type or message, please read the guideline first in 'core/src/main/resources/error/README.md'. --> In order to fix DROP table behavior in session catalog cause by apache#37879. Because we always invoke V1 drop logic if the identifier looks like a V1 identifier. This is a big blocker for external data sources that provide custom session catalogs. So this PR move all Drop Table case to DataSource V2 (use drop table to drop view not include). More information please check https://github.com/apache/spark/pull/37879/files#r1170501180 <!-- Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below. 1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers. 3. If you fix some SQL features, you can provide some references of other DBMSes. 4. If there is design documentation, please add the link. 5. If there is a discussion in the mailing list, please add the link. --> Move Drop Table case to DataSource V2 to fix bug and prepare for remove drop table v1. <!-- Please clarify why the changes are needed. For instance, 1. If you propose a new API, clarify the use case for a new API. 2. If you fix a bug, you can clarify why it is a bug. --> No <!-- Note that it means *any* user-facing change including all aspects such as the documentation fix. If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible. If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master. If no, write 'No'. --> Tested by: - V2 table catalog tests: `org.apache.spark.sql.execution.command.v2.DropTableSuite` - V1 table catalog tests: `org.apache.spark.sql.execution.command.v1.DropTableSuiteBase` <!-- If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible. If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future. If tests were not added, please describe why they were not added and/or why it was difficult to add. If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks. --> Closes apache#41348 from Hisoka-X/SPARK-43203_drop_table_to_v2. Authored-by: Jia Fan <[email protected]> Signed-off-by: Wenchen Fan <[email protected]> (cherry picked from commit 32a5db4)
… null table ### What changes were proposed in this pull request? This is a followup of apache#41348 . Previously `V2SessionCatalog.dropTable` treated null table as table not exists, but apache#41348 broke it. This PR fixes it. ### Why are the changes needed? to keep old behavior. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? existing tests Closes apache#42056 from cloud-fan/mm. Authored-by: Wenchen Fan <[email protected]> Signed-off-by: Kent Yao <[email protected]>
|
I found if you create a management table in spark 3.5.1, you cannot delete the path when dropping the table. I think this is a bug. It can be deleted correctly in spark 3.3. |
|
|
@gaecoli thanks for reporting the bug! Can you create a JIRA ticket and include the reproduce steps? |
i don't have permission to connect to spark jira |
|
or you can post the problem description and repro here and I can help to create the ticket. |
What changes were proposed in this pull request?
In order to fix DROP table behavior in session catalog cause by #37879. Because we always invoke V1 drop logic if the identifier looks like a V1 identifier. This is a big blocker for external data sources that provide custom session catalogs.
So this PR move all Drop Table case to DataSource V2 (use drop table to drop view not include). More information please check https://github.com/apache/spark/pull/37879/files#r1170501180
Why are the changes needed?
Move Drop Table case to DataSource V2 to fix bug and prepare for remove drop table v1.
Does this PR introduce any user-facing change?
No
How was this patch tested?
Tested by:
org.apache.spark.sql.execution.command.v2.DropTableSuiteorg.apache.spark.sql.execution.command.v1.DropTableSuiteBase