获取BigQuery项目中所有BigQuery表的最后访问日期 [英] Get the Last Access date for all BigQuery tables in a BigQuery Project
本文介绍了获取BigQuery项目中所有BigQuery表的最后访问日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道如何获取上次修改表但未访问表的日期.是否可以获取上次读取表的时间?是否有查询或API来获取此信息?
I know how to get the date a table was last modified, but not accessed. Is it possible to get the last time a table was read ? Is there query or an API to get this ?
推荐答案
如果您有审核日志在BigQuery中,您可以编写如下查询:
If you have audit logs in BigQuery, you can write a query like this:
WITH tables AS (
SELECT FORMAT("%s.%s.%s", table.projectId, table.datasetId, table.tableId) table
, MAX(timestamp) last_access
FROM (
SELECT timestamp
, protopayload_auditlog.servicedata_v1_bigquery.jobCompletedEvent.job.jobStatistics.referencedTables
FROM `fh-bigquery.audit.cloudaudit_googleapis_com_data_access_201811*`
), UNNEST(referencedTables) table
GROUP BY 1
)
SELECT *
FROM tables
这篇关于获取BigQuery项目中所有BigQuery表的最后访问日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文