Skip to content
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

Feat : undrop table & show history #5562

Merged
merged 8 commits into from
May 25, 2022

Conversation

dantengsky
Copy link
Member

@dantengsky dantengsky commented May 24, 2022

I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/

Summary

undrop table .. and show tables history .. (legacy parser only)

  • show tables history
mysql> drop table t4;
mysql> show tables history like 't4';
+-------------------+-------------------------------+
| Tables_in_default | drop_time                     |
+-------------------+-------------------------------+
| t4                | 2022-05-25 05:56:49.622 +0000 |
+-------------------+-------------------------------+
  • undrop table
mysql> undrop table t4;
Query OK, 0 rows affected (0.05 sec)
Read 0 rows, 0.00 B in 0.023 sec., 0 rows/sec., 0.00 B/sec.

mysql> show tables;
+-------------------+
| Tables_in_default |
+-------------------+
| t4                |
+-------------------+
2 rows in set (0.07 sec)
Read 98 rows, 14.07 KiB in 0.044 sec., 2.22 thousand rows/sec., 318.62 KiB/sec.

mysql> show tables history like 't4';
+-------------------+-----------+
| Tables_in_default | drop_time |
+-------------------+-----------+
| t4                | NULL      |
+-------------------+-----------+
1 row in set (0.07 sec)
Read 98 rows, 14.07 KiB in 0.044 sec., 2.25 thousand rows/sec., 322.68 KiB/sec.

NOTE:

  1. during checking the quota max_tables_per_database, historical dropped tables are NOT counted
  2. There is no dedicate privilege for the undrop operation, UserPrivilegeType::Drop is used
  3. schema changes of system tables: @flaneur2020
    • An extra column dropped_on is added to system.tables
    • An extra column drop_time is added to information_schema.tables
  4. only the legacy parser recognize these new statements @andylokandy
    test case test_statements_in_legacy_suites of common/ast/tests/it/parser.rs been tweaked accordingly
  5. drop table no longer delete data @wubx @BohuTANG
    please use truncate table & optimize table purge instead
  6. Non fuse tables, could also be undropped, which may not be reasonable.

Changelog

  • New Feature
  • Not for changelog (changelog entry is not required)

Related Issues

Fixes #5561

@vercel
Copy link

vercel bot commented May 24, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated
databend ⬜️ Ignored (Inspect) May 25, 2022 at 10:48AM (UTC)

@mergify
Copy link
Contributor

mergify bot commented May 24, 2022

Thanks for the contribution!
I have applied any labels matching special text in your PR Changelog.

Please review the labels and make any necessary changes.

@mergify mergify bot added pr-feature this PR introduces a new feature to the codebase pr-not-for-changelog labels May 24, 2022
@dantengsky dantengsky changed the title Feat undrop table show history Feat : undrop table & show history May 25, 2022
@dantengsky dantengsky force-pushed the feat-undrop-table-show-history branch from 49e2227 to ec1db2c Compare May 25, 2022 08:25
@dantengsky dantengsky marked this pull request as ready for review May 25, 2022 09:34
let catalog_name = self.plan.catalog.as_str();
let db_name = self.plan.db.as_str();

// shall we add UserPrivilege::Type::UnDrop ?
Copy link
Member

Choose a reason for hiding this comment

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

@BohuTANG
Copy link
Member

Added pr-need-doc label, cc @soyeric128

@dantengsky dantengsky added this to the v0.8 milestone May 25, 2022
@BohuTANG BohuTANG merged commit 486b866 into datafuselabs:main May 25, 2022
@BohuTANG BohuTANG mentioned this pull request May 25, 2022
@soyeric128
Copy link
Collaborator

Hi @dantengsky and @BohuTANG ,

Could you pls confirm if the commands UNDROP and SHOW TABLES HISTORY work with a policy like Data Retention Period? That means only dropped tables still within the retention period can be restored or displayed. If so, please provide more information about the retention policy. Thanks.

@BohuTANG
Copy link
Member

Hi, @soyeric128

I think we don't have the retention policy yet. We only have the UNDROP statement.
We can wait a few times for that feature to be finished, let's document them then.

Let's ignore this PR to document for now.

@dantengsky
Copy link
Member Author

Hi @dantengsky and @BohuTANG ,

Could you pls confirm if the commands UNDROP and SHOW TABLES HISTORY work with a policy like Data
...

@soyeric128

Sorry, missed your question totally...
we do not have the whole retention policy yet,

@BohuTANG
Copy link
Member

I have updated the UNDROP TABLE to databend.rs:
https://databend.rs/doc/reference/sql/ddl/table/ddl-undrop-table

cc @soyeric128

@soyeric128
Copy link
Collaborator

Hi @dantengsky and @BohuTANG ,
Could you pls confirm if the commands UNDROP and SHOW TABLES HISTORY work with a policy like Data
...

@soyeric128

Sorry, missed your question totally... we do not have the whole retention policy yet,

Thanks for the reply, @dantengsky. Please let me know when the retention policy is ready, then we can start the document updating. Thank you.

@soyeric128
Copy link
Collaborator

I have updated the UNDROP TABLE to databend.rs: https://databend.rs/doc/reference/sql/ddl/table/ddl-undrop-table

cc @soyeric128

Thanks for the updates. Can we update the description a little bit to be more precise?

Restores the recent version of a dropped table. -> Restore the most recent version of a dropped table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-review pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: undrop table & show tables history
5 participants