1

I would like to get only table names from BigQuery by using wildcard in Python.
What I want to do is something like this:

from google.cloud import bigquery
bigquery_client = bigquery.Client()
table_names = bigquery_client.get_something().something('db_name.table_prefix_*')

Can I do something like this?
If I can, What should I do?

2 Answers 2

4

Table metadata details available in the INFORMATION_SCHEMA. You can run the following query and get the table names using Python SDK.

Query:

SELECT table_name FROM YOUR_DATASET.INFORMATION_SCHEMA.TABLES where table_name like 'table_prefix_%'

Reference:

https://cloud.google.com/bigquery/docs/information-schema-tables

https://cloud.google.com/bigquery/docs/running-queries#python

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. you save my day!
2

I did as SANN3 taught me, like a following:

query = '''select table_name from my_dataset_name.INFORMATION_SCHEMA.TABLES where table_name like 'table_prefix_%' '''
table_names = bigquery_client.query(query).result().to_dataframe()
print(table_names)

then I got table_names :-)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.