bigquery-emulator
bigquery-emulator copied to clipboard
Deleting a dataset dont seem to remove tables
It seems like deleting a dataset doesnt "cascade" to a tables:
$ bq --api http://127.0.0.1:9050 --project_id=test-project-bla mk test-dataset-bla
Dataset 'test-project-bla:test-dataset-bla' successfully created.
$ bq --api http://127.0.0.1:9050 --project_id=test-project-bla mk test-dataset-bla.t1
Table 'test-project-bla:test-dataset-bla.t1' successfully created.
$ bq --api http://127.0.0.1:9050 --project_id=test-project-bla rm test-dataset-bla
rm: remove dataset 'test-project-bla:test-dataset-bla'? (y/N) y
$ bq --api http://127.0.0.1:9050 --project_id=test-project-bla mk test-dataset-bla
Dataset 'test-project-bla:test-dataset-bla' successfully created.
$ bq --api http://127.0.0.1:9050 --project_id=test-project-bla mk test-dataset-bla.t1
BigQuery error in mk operation: failed to exec INSERT INTO `tables` (`id`,`projectID`,`datasetID`,`metadata`) VALUES
(@id,@projectid,@datasetid,@metadata): UNIQUE constraint failed: tables.projectID, tables.datasetID, tables.id
If the error provided does not help solve your issue, please run the command again with the `--apilog=stderr flag`.
I briefly mentioned this in a comment on #160
The bug here is actually that the dataset is removed when it still contains tables. As noted in datasets.delete a dataset cannot be deleted until it does not contain any tables.
If you were to run the following, then the tables in the dataset would also be deleted.
bq --api http://127.0.0.1:9050 --project_id=test-project-bla rm -r test-dataset-bla