获取 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 ?
解决方案
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屋!
查看全文