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: delete table #25572

Merged
merged 1 commit into from
Nov 22, 2024
Merged

feat: delete table #25572

merged 1 commit into from
Nov 22, 2024

Conversation

praveen-influx
Copy link
Contributor

This commit allows deleting (soft) a table. For an user, following command will allow soft deleting a table (bar) in db (foo)

influxdb3 table delete --dbname foo --table bar --host $host
  • Added soft_delete_table to DatabaseManager trait, which already hosts soft_delete_database method. The code roughly follows the same flow as db delete. Although like db schema, it does clone on write because the reference is behind an Arc, Arc::make_mut is used in this change.
  • Moved db delete related cli parser under "manage" module that has both db and table delete functionality
  • Some minor tidyups (removing unused methods, renaming method so that the order in name matches actual return type eg. table_id_and_schema, should return (id, schema) and not (schema, id))

closes: #25561

This commit allows deleting (soft) a table. For an user, following
command will allow soft deleting a table (bar) in db (foo)

```
influxdb3 table delete --dbname foo --table bar --host $host
```

- Added `soft_delete_table` to `DatabaseManager` trait, which already
  hosts `soft_delete_database` method. The code roughly follows the same
  flow as db delete. Although like db schema, it does clone on write
  because the reference is behind an Arc, `Arc::make_mut` is used in
  this change.
- Moved db delete related cli parser under "manage" module that has both
  db and table delete functionality
- Some minor tidyups (removing unused methods, renaming method so that
  the order in name matches actual return type eg. `table_id_and_schema`,
  should return (id, schema) and not (schema, id))

closes: #25561
Copy link
Contributor

@hiltontj hiltontj left a comment

Choose a reason for hiding this comment

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

This is awesome work, LGTM. The DatabaseManager trait should make porting this up into pro much smoother.

let deletion_time = Time::from_timestamp_nanos(deleted_table_defn.deletion_time);
let table_name =
make_new_name_using_deleted_time(&deleted_table_defn.table_name, deletion_time);
let new_table_def = Arc::make_mut(deleted_table);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice use of Arc::make_mut

@praveen-influx praveen-influx merged commit 3cde24f into main Nov 22, 2024
13 checks passed
@hiltontj hiltontj added the v3 label Nov 22, 2024
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.

Add delete table
2 participants