in bigquery_etl/view/broken_views.py [0:0]
def list_views(client, pool, project_id, only_tables, table_filter):
"""Make parallel BQ API calls to grab all views.
See `util.standard_ for more context on table filtering.
:param client: A BigQuery client object
:param pool: A process pool for handling concurrent calls
:param project_id: Target project
:param only_tables: An iterable of globs in `<dataset>.<view>` format
:param table_filter: A function for determining whether to include a view
:return: A list of matching views
"""
if only_tables and not _contains_glob(only_tables):
# skip list calls when only_tables exists and contains no globs
return [f"{project_id}.{t}" for t in only_tables if table_filter(t)]
if only_tables and not _contains_glob(
_extract_dataset_from_glob(t) for t in only_tables
):
# skip list_datasets call when only_tables exists and datasets contain no globs
datasets = {
f"{project_id}.{_extract_dataset_from_glob(t)}" for t in only_tables
}
else:
datasets = [d.reference.dataset_id for d in client.list_datasets(project_id)]
return [
sql_table_id(t)
for tables in pool.map(client.list_tables, datasets)
for t in tables
if table_filter(f"{t.dataset_id}.{t.table_id}") and t.table_type == "VIEW"
]