我知道如何获取上次修改表但未访问表的日期。是否有可能最后一次读取表?是否有查询或API来获取此信息?
答案 0 :(得分:0)
如果BigQuery中有audit logs,则可以编写如下查询:
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