Skip to content

Conversation

@Hisoka-X
Copy link
Member

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:

  • V2 table catalog tests: org.apache.spark.sql.execution.command.v2.DropTableSuite
  • V1 table catalog tests: org.apache.spark.sql.execution.command.v1.DropTableSuiteBase

@github-actions github-actions bot added the SQL label May 28, 2023
@Hisoka-X
Copy link
Member Author

cc @aokolnychyi @cloud-fan @viirya

@Hisoka-X Hisoka-X force-pushed the SPARK-43203_drop_table_to_v2 branch from 39268a4 to bfd7c2f Compare May 28, 2023 16:44
isSameName(ident.qualifier :+ ident.name) &&
isSameName(v1Ident.catalog.toSeq ++ v1Ident.database :+ v1Ident.table)

case SubqueryAlias(ident, HiveTableRelation(catalogTable, _, _, _, _)) =>
Copy link
Member Author

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 =>
Copy link
Member Author

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.

Copy link
Contributor

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?

Copy link
Member Author

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.

@Hisoka-X Hisoka-X requested a review from cloud-fan June 6, 2023 12:45
@viirya
Copy link
Member

viirya commented Jun 8, 2023

Is the test failure related?

DataFrameFunctionsSuite.DataFrame function and SQL functon parity
org.scalatest.exceptions.TestFailedException: Set("ceiling", "negative", "std", "sign") was not empty

@Hisoka-X
Copy link
Member Author

Hisoka-X commented Jun 9, 2023

Is the test failure related?

DataFrameFunctionsSuite.DataFrame function and SQL functon parity
org.scalatest.exceptions.TestFailedException: Set("ceiling", "negative", "std", "sign") was not empty

I think not, many PR can't pass sql - other tests at now. Seem ci have something wrong.

@Hisoka-X
Copy link
Member Author

Could you re-trigger CI?

Done, please wait.

@Hisoka-X
Copy link
Member Author

@cloud-fan @viirya Hi folks, the CI passed. Can we move forward next step?

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in 32a5db4 Jun 19, 2023
@Hisoka-X Hisoka-X deleted the SPARK-43203_drop_table_to_v2 branch June 19, 2023 12:44
@Hisoka-X
Copy link
Member Author

Thanks @cloud-fan @viirya

@aokolnychyi
Copy link
Contributor

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?

@viirya
Copy link
Member

viirya commented Jun 27, 2023

I'm okay with changing it to bug and backport to 3.4.2. cc @cloud-fan

Hisoka-X added a commit to Hisoka-X/spark that referenced this pull request Jun 28, 2023
<!--
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)
yaooqinn pushed a commit that referenced this pull request Jul 18, 2023
… 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]>
yaooqinn pushed a commit that referenced this pull request Jul 18, 2023
… 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]>
Hisoka-X pushed a commit to Hisoka-X/spark that referenced this pull request Jul 26, 2023
… 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)
Hisoka-X added a commit to Hisoka-X/spark that referenced this pull request Aug 29, 2023
<!--
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)
Hisoka-X pushed a commit to Hisoka-X/spark that referenced this pull request Aug 29, 2023
… 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)
dongjoon-hyun pushed a commit that referenced this pull request Sep 8, 2023
### 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]>
viirya pushed a commit to viirya/spark-1 that referenced this pull request Oct 19, 2023
<!--
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)
viirya pushed a commit to viirya/spark-1 that referenced this pull request Oct 19, 2023
… 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]>
@gaecoli
Copy link

gaecoli commented Aug 20, 2024

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
Copy link

gaecoli commented Aug 20, 2024

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.

@cloud-fan

@cloud-fan
Copy link
Contributor

@gaecoli thanks for reporting the bug! Can you create a JIRA ticket and include the reproduce steps?

@gaecoli
Copy link

gaecoli commented Aug 20, 2024

@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

@cloud-fan
Copy link
Contributor

or you can post the problem description and repro here and I can help to create the ticket.

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.

5 participants