我有数据导入管道进入BigQuery表(每小时表名为transactions_20170616_00 transactions_20170616_01 ......还有更多每日/每周/ ...汇总),想要使用单个视图始终指向最新的一个,找到很难做一个静态标准SQL视图指向最新,我目前的解决方案是在每次导入成功后将视图的内容更新为SELECT * FROM project.dataset.transactions_201706....
,
直到我读到这个httparchive的最新观点:这就是我想要的东西,但是在遗留SQL中;我的项目只使用所有标准SQL,而更喜欢标准SQL,因为它是未来;想知道如何将这个遗留SQL转换为标准SQL?那么我不需要不断更新我的观点 https://bigquery.cloud.google.com/table/httparchive:runs.latest_requests?tab=details
SELECT *
FROM TABLE_QUERY(httparchive:runs,
"table_id IN (
SELECT table_id FROM [httparchive:runs.__TABLES__]
WHERE REGEXP_MATCH(table_id, '2.*requests$')
ORDER BY table_id DESC LIMIT 1)")
按照本指南,我正在尝试使用 https://cloud.google.com/bigquery/docs/querying-wildcard-tables#the_table_query_function
#standardSQL
SELECT * FROM `httparchive.runs.*`
WHERE _TABLE_SUFFIX IN
( SELECT table_id
FROM httparchive.runs.__TABLES__
WHERE REGEXP_CONTAINS(table_id, r'2.*requests$')
ORDER BY table_id DESC
LIMIT 1)
但查询失败了
Query Failed
Error: Views cannot be queried through prefix. Matched views are: httparchive:runs.latest_pages, httparchive:runs.latest_pages_mobile, httparchive:runs.latest_requests, httparchive:runs.latest_requests_mobile
Job ID: bidder-1183:bquijob_1400109e_15cb1dc3c0c
我发现通配符只能在最后使用?在这种情况下,为什么不SELECT * FROM httparchive.runs.*_requests WHERE ...
工作?
在这种情况下,它是说标准SQL中的通配符表功能与legacySQL>中的TABLE_QUERY不一样灵活吗?