Skip to content

feat: delete table#25572

Merged
praveen-influx merged 1 commit intomainfrom
praveen/drop-table
Nov 22, 2024
Merged

feat: delete table#25572
praveen-influx merged 1 commit intomainfrom
praveen/drop-table

Conversation

@praveen-influx
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

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