Skip to content

[hotfix] Fix drop database not working in terminal#3363

Merged
zhoujinsong merged 10 commits into
apache:masterfrom
MarigWeizhi:spark_catalog
Dec 31, 2024
Merged

[hotfix] Fix drop database not working in terminal#3363
zhoujinsong merged 10 commits into
apache:masterfrom
MarigWeizhi:spark_catalog

Conversation

@MarigWeizhi
Copy link
Copy Markdown
Contributor

@MarigWeizhi MarigWeizhi commented Dec 10, 2024

Why are the changes needed?

Close #xxx.

Brief change log

  • Added the dropNamespace to support cascade or non-cascade in SparkUnifiedCatalogBase for spark 3.3
  • spark 3.2 will use false by default

How was this patch tested?

  • Add some test cases that check the changes thoroughly including negative and positive cases if possible

  • Add screenshots for manual tests if appropriate

  • Run test locally before making a pull request

Documentation

  • Does this pull request introduce a new feature? ( no)
  • If yes, how is the feature documented? (not documented)

@github-actions github-actions Bot added the module:mixed-spark Spark module for Mixed Format label Dec 10, 2024
@MarigWeizhi MarigWeizhi changed the title [hotfix] Implement dropNamespace [hotfix] Fix drop database not working in terminal Dec 10, 2024
Copy link
Copy Markdown
Contributor

@huyuanfeng2018 huyuanfeng2018 left a comment

Choose a reason for hiding this comment

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

Should we add a test to guard against future regression?

@MarigWeizhi
Copy link
Copy Markdown
Contributor Author

Should we add a test to guard against future regression?

Added test, PTAL

Copy link
Copy Markdown
Contributor

@huyuanfeng2018 huyuanfeng2018 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

throw new NoSuchNamespaceException(namespace);
}
List<TableIDWithFormat> tables = unifiedCatalog.listTables(database);
if (!tables.isEmpty() && !cascade) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not drop all tables first and then drop the database?

I think should this logic be implemented directly by the parent (spark-common).
We already have concrete logic in SparkUnifiedCatalogBase.dropNamespace.
so,remove Override is enough.

WDYT?

Copy link
Copy Markdown
Contributor

@zhoujinsong zhoujinsong Dec 20, 2024

Choose a reason for hiding this comment

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

I agreed that we may reuse some implementation in the parent class. However I think it is dangerous to delete all tables by default in Spark 3.2 implementation. So we may:

  • Add a method in the base class to support dropping namespace cascade or not.
  • Drop namespace by default with false for Spark 3.2

@MarigWeizhi
Copy link
Copy Markdown
Contributor Author

MarigWeizhi commented Dec 20, 2024

Thanks for your review @zhoujinsong @huyuanfeng2018
I updated the code, I implemented the method to support cascade or non-cascade in base instead of spark 3.3.
spark 3.2 will use false by default

Copy link
Copy Markdown
Contributor

@huyuanfeng2018 huyuanfeng2018 left a comment

Choose a reason for hiding this comment

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

just a nit comment

Copy link
Copy Markdown
Contributor

@huyuanfeng2018 huyuanfeng2018 left a comment

Choose a reason for hiding this comment

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

LGTM.

@zhoujinsong zhoujinsong merged commit 907973e into apache:master Dec 31, 2024
@zhoujinsong
Copy link
Copy Markdown
Contributor

Thanks for the contribution! @MarigWeizhi
Thanks for the review! @huyuanfeng2018

zhoujinsong pushed a commit to zhoujinsong/amoro that referenced this pull request Jan 21, 2025
* Implement dropNamespace

* test namespace for SparkUnifiedCatalog

* Implement cascade or non-cascading drop namespace in base

* Restore private

* fix

* Remove redundant method

---------

Co-authored-by: big face cat <731030576@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:mixed-spark Spark module for Mixed Format

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants