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: list_tables accepts a DatasetListItem #588

Closed
tswast opened this issue Apr 6, 2021 · 1 comment · Fixed by #597
Closed

feat: list_tables accepts a DatasetListItem #588

tswast opened this issue Apr 6, 2021 · 1 comment · Fixed by #597
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 Apr 6, 2021

Is your feature request related to a problem? Please describe.

Code:

for dataset in bqclient.list_datasets():
    tables = list(bqclient.list_tables(dataset, max_results=1))
    if len(tables) == 0:
        bqclient.delete_dataset(dataset)

Output:

Traceback (most recent call last):
  File "2021/04-test-dataset-cleanup/cleanup.py", line 11, in <module>
    tables = len(bqclient.list_tables(dataset, max_results=1))
  File "/Users/swast/miniconda3/envs/scratch/lib/python3.8/site-packages/google/cloud/bigquery/client.py", line 1327, in list_tables
    raise TypeError("dataset must be a Dataset, DatasetReference, or string")
TypeError: dataset must be a Dataset, DatasetReference, or string

Describe the solution you'd like

Where Dataset or DatasetReference is accepted, also accept a DatasetListItem.

Describe alternatives you've considered

I know that we created DatasetListItem.reference, which I can use, but it'd be a bit more intuitive if I didn't have to.

Additional context

N/A

@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery API. label Apr 6, 2021
@tswast tswast added the type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. label Apr 6, 2021
@tswast tswast changed the title feat: list_tables accepts a DatasetListItem feat: list_tables accepts a DatasetListItem Apr 6, 2021
@tswast
Copy link
Contributor Author

tswast commented Apr 6, 2021

In addition to list_tables, any method that takes a DatasetReference but not a DatasetListItem should be updated.

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