[英]Getting dates from multiple dataset
I am trying to get the list of tables and their last_modified_date using bigquery.我正在尝试使用 bigquery 获取表列表及其 last_modified_date。 using below code i can get the last modified time from one dataset.
使用下面的代码,我可以从一个数据集中获取最后修改时间。 But i want to know how to get the last modified data from multiple dataset
但我想知道如何从多个数据集中获取最后修改的数据
query = """SELECT
dataset_id,
table_id,
-- Convert UNIX EPOCH to a timestamp.
TIMESTAMP_MILLIS(creation_time) AS creation_time,
TIMESTAMP_MILLIS(last_modified_time) as last_modified_time
FROM
`project.dataset.__TABLES__`;"""
To expand the scope of what tables returned use the following to grab all the tables within the project for the provided region (example for us region):要扩展返回的表的 scope,请使用以下命令获取项目中提供区域的所有表(例如我们区域):
SELECT
dataset_id,
table_id,
-- Convert UNIX EPOCH to a timestamp.
TIMESTAMP_MILLIS(creation_time) AS creation_time,
TIMESTAMP_MILLIS(last_modified_time) as last_modified_time
FROM
project.`region-us`.INFORMATION_SCHEMA.TABLES
For more documentation see here: https://cloud.google.com/bigquery/docs/information-schema-tables#scope_and_syntax有关更多文档,请参见此处: https://cloud.google.com/bigquery/docs/information-schema-tables#scope_and_syntax
To find metadata of the dataset you need to call INFORMATION_SCHEMA.SCHEMATA and find the metadata of table INFORMATION_SCHEMA.TABLES .要查找数据集的元数据,您需要调用INFORMATION_SCHEMA.SCHEMATA并查找表INFORMATION_SCHEMA.TABLES的元数据。
For example:例如:
SELECT
t2.table_schema,
t2.table_name,
t2.creation_time,
t1.last_modified_time
FROM
region-us.INFORMATION_SCHEMA.SCHEMATA t1
INNER JOIN
region-us.INFORMATION_SCHEMA.TABLES t2
ON
t1.schema_name=t2.table_schema;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.