问题
I am trying to find the table of the current date of
SELECT *
FROM `da`.`m`.`ga_realtime_20190306`
but not working
SELECT *
FROM `da`.`m`.`CONCAT('ga_realtime_', FORMAT_DATE('%Y%m%d', CURRENT_DATE())`
How can I dynamically select a table with CURRENT_DATE
and the BigQuery Standard query?
回答1:
Use wildcard and _TABLE_SUFFIX
SELECT
field1,
field2,
field3
FROM
`my_dataset.ga_realtime_*`
WHERE
_TABLE_SUFFIX = FORMAT_DATE('%Y%m%d', CURRENT_DATE())
来源:https://stackoverflow.com/questions/57817881/bigquery-dynamically-select-table-by-the-current-date-in-standard-sql