可以通过使用BigQuery内置的 INFORMATION_SCHEMA.TABLES 元数据视图来获取其它数据集中表的分区计数。以下是一个示例查询,展示了不同数据集的所有表及其分区计数:
SELECT
CONCAT(table_catalog, '.', table_schema, '.', table_name) AS table_id,
partition_count
FROM
`project_id.INFORMATION_SCHEMA.TABLES`
WHERE
table_type = 'BASE TABLE'
AND table_catalog = 'project_id'
ORDER BY
table_id ASC
请将 "project_id" 替换为您的项目ID。如果要列出所有数据集中的分区计数,可使用以下查询:
SELECT
CONCAT(table_catalog, '.', table_schema, '.', table_name) AS table_id,
partition_count
FROM
`project_id.INFORMATION_SCHEMA.TABLES`
WHERE
table_type = 'BASE TABLE'
ORDER BY
table_id ASC
这将返回所有数据集中的表及其分区计数。