简体   繁体   English

从多个数据集中获取日期

[英]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.

相关问题 在 GET 请求中使用多个参数从 DynamoDB 获取数据 - Getting data from DynamoDB using multiple parameters in GET Request 如何从 Firebase 获取所有日期并在日历中标记日期 - How to get all the dates from Firebase and mark the dates in Calendar 从 GCP 存储桶查询 pyarrow 数据集非常慢 - Query pyarrow dataset from GCP bucket is extremely slow Select 不同数据集测试时 | 将测试与生产分开 - Select different dataset when testing | Separate test from production 如何从给定日期开始将 BigQuery 数组的元素与日期匹配? - How to match elements of a BigQuery array with dates by starting from a given date? Firebase 中的 onDataChange() 被多次触发 - onDataChange() in Firebase getting triggered multiple times 如何在多个星期的两个日期之间使用 CASE 语句创建自定义的“一年中的一周”? - How can I create a custom 'Week of Year' using a CASE Statement BETWEEN two dates over multiple weeks? 在 Swift 中从 NsDIctionary 获取价值 - Getting value from NsDIctionary in Swift 如何从 Python 训练代码中的 Vertex AI 托管数据集中加载图像? - How to load images from Vertex AI managed dataset inside Python training code? 从 golang 中的 package 获取导出函数列表 - Getting list of exported functions from a package in golang
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM