I want to export data to csv and save it to Google Storage using EXPORT DATA in Standard Query. It will be saved as scheduled query. Then, I set the table suffix into dynamic according to yesterday's date. Unfortunately, Bigquery didn't allow using the _TABLE_SUFFIX and resulted a warning of
"EXPORT DATA statement cannot reference meta tables in the queries."
It might mean I should use a static table name. But, in this case, I can only use table name with changing name according to yesterday date. Do you have any idea how to work around with this problem? Thank you.
EXPORT DATA OPTIONS(
uri=CONCAT('gs://my_data//table1_', CONCAT(FORMAT_DATE("%Y%m%d",CURRENT_DATE()-1),'*.csv')),
format='CSV',
overwrite=true,
header=true,
field_delimiter=',') AS
SELECT *
FROM `mybigquery.123456.ga_sessions_*`
WHERE
_TABLE_SUFFIX = FORMAT_DATE("%Y%m%d",CURRENT_DATE()-1)