diff --git a/docs/how-to/data-hub/delete.md b/docs/how-to/data-hub/delete.md index c8051c4..6426594 100644 --- a/docs/how-to/data-hub/delete.md +++ b/docs/how-to/data-hub/delete.md @@ -34,24 +34,23 @@ To delete multiple rows, databases and folders, run: ## Delete database columns -To delete columns in databases, run: +To delete columns in databases, run the following command, specifying the IDs of the columns to delete and their parent database: === "CLI" ```bash - deeporigin data delete --ids --columns + deeporigin data delete \ + --ids \ + --database \ + --columns ``` - !!! warning "Column IDs" - Currently, columns can only be deleted using their IDs, which are distinct from their names. To view the IDs of the columns of a database, run: - - ```bash - deeporigin data describe - ``` - === "Python" ```py from deeporigin.data_hub import api - api.delete_database_column(column_id="col-id") + api.delete_database_column( + column_id="col-id", + database_id="database-id", + ) ``` diff --git a/pyproject.toml b/pyproject.toml index ca78bb8..c6ea666 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,7 @@ dependencies = [ "tabulate", "filetype", "httpx", - "deeporigin-data-sdk>=0.1.0a6", + "deeporigin-data-sdk==0.1.0a7", ] dynamic = ["version"] diff --git a/src/cli/data.py b/src/cli/data.py index e5d532c..04ae39f 100644 --- a/src/cli/data.py +++ b/src/cli/data.py @@ -567,17 +567,18 @@ def new(self): }, ), ( - ["--columns"], + ["--database"], { - "action": "store_true", - "help": "Whether to delete columns or rows/databases/folders [default: False]", + "type": str, + "required": False, + "help": "ID of database that columns are in", }, ), ( - ["--json"], + ["--columns"], { "action": "store_true", - "help": "Whether to return data in JSON format [default: False]", + "help": "Whether to treat IDs as column IDs [default: False]", }, ), ], @@ -586,9 +587,14 @@ def delete(self): """Delete rows, columns, databases and/or folders""" if self.app.pargs.columns: + if self.app.pargs.database is None: + raise DeepOriginException( + "Use the --database argument to specify the parent database. To delete a column, the parent database must be specified." + ) for column_id in self.app.pargs.ids: api.delete_database_column( column_id=column_id, + database_id=self.app.pargs.database, client=self._get_client(), ) print(f"✔︎ Deleted {len(self.app.pargs.ids)} columns")