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

Allow DatasetListItem in Client.delete_dataset types #995

Closed
tswast opened this issue Sep 29, 2021 · 4 comments · Fixed by #1017
Closed

Allow DatasetListItem in Client.delete_dataset types #995

tswast opened this issue Sep 29, 2021 · 4 comments · Fixed by #1017
Assignees
Labels
api: bigquery Issues related to the googleapis/python-bigquery API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@tswast
Copy link
Contributor

tswast commented Sep 29, 2021

https://app.circleci.com/pipelines/github/tswast/python-bigquery-pandas/217/workflows/38a35d17-9e68-48b3-b17a-b683e4ab5a52/jobs/1308

I expected this code to work:

    @pytest.fixture(scope="session", autouse=True)
    def cleanup_datasets(bigquery_client: bigquery.Client):
        for dataset in bigquery_client.list_datasets():
            if prefixer.should_cleanup(dataset.dataset_id):
                bigquery_client.delete_dataset(
>                   dataset, delete_contents=True, not_found_ok=True
                )

But I get

if not isinstance(dataset, (Dataset, DatasetReference)):
>           raise TypeError("dataset must be a Dataset or a DatasetReference")
E           TypeError: dataset must be a Dataset or a DatasetReference

/opt/conda/envs/test-environment/lib/python3.7/site-packages/google/cloud/bigquery/client.py:740: TypeError

Similarly, we should check delete_table. I think it accepts TableListItem, but this is not reflected in the type annotations.

@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery API. label Sep 29, 2021
@tswast tswast added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed api: bigquery Issues related to the googleapis/python-bigquery API. labels Sep 29, 2021
@tswast
Copy link
Contributor Author

tswast commented Sep 29, 2021

@steffnay This might be a good one to take on if you're looking for issues to get warmed up on the Python client.

@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery API. label Sep 30, 2021
@steffnay
Copy link
Contributor

steffnay commented Oct 7, 2021

@tswast could you please clarify for me whether this TypeError was not fixed by #597 or if the issue here is that the type needs to be updated here?

@tswast
Copy link
Contributor Author

tswast commented Oct 7, 2021

Oops.

https://github.com/googleapis/python-bigquery-pandas/blob/6ae6629db0aec48ecd37a96a75f950fea63405c7/testing/constraints-3.7.txt#L12

This test suite was running with an older version of the google-cloud-bigquery library.

Sorry for the noise.

@tswast tswast closed this as completed Oct 7, 2021
@tswast tswast reopened this Oct 7, 2021
@tswast
Copy link
Contributor Author

tswast commented Oct 7, 2021

dataset: Union[Dataset, DatasetReference, str],
does still need to be updated though, yes.

@tswast tswast changed the title Allow DatasetListItem in Client.delete_dataset Allow DatasetListItem in Client.delete_dataset types Oct 7, 2021
gcf-merge-on-green bot pushed a commit that referenced this issue Oct 11, 2021
_Thank_ you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
- [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-bigquery/issues/new/choose) before writing your code!  That way we can discuss the change, evaluate designs, and agree on the general idea
- [ ] Ensure the tests and linter pass
- [ ] Code coverage does not decrease (if any source code was changed)
- [ ] Appropriate docs were updated (if necessary)

Fixes #995 🦕
abdelmegahedgoogle pushed a commit to abdelmegahedgoogle/python-bigquery that referenced this issue Apr 17, 2023
_Thank_ you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
- [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-bigquery/issues/new/choose) before writing your code!  That way we can discuss the change, evaluate designs, and agree on the general idea
- [ ] Ensure the tests and linter pass
- [ ] Code coverage does not decrease (if any source code was changed)
- [ ] Appropriate docs were updated (if necessary)

Fixes googleapis#995 🦕
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants