So I've got a tables being imported daily from firebase and I'm exporting them from google cloud to power bi. The naming schema stays roughly the same, the only thing that changes daily is the date at the end of the table name. Been trying to create a query that makes the process fully automated, but I've been stuck. The concat is correct, but the string doesn't work to call from. Help is appreciated.
DECLARE Query STRING(100);
SET Query = CONCAT("report-viewer.analytics_278375497.events_", FORMAT_DATE("%Y%m%d", CURRENT_DATE()));
SELECT
//Various stuff
FROM Query LIMIT 1000
You should use EXECUTE IMMEDIATE in this scenario
Using your particular simplified example - it could look like below
DECLARE table_reference STRING(100);
SET table_reference = 'report-viewer.analytics_278375497.events_' || FORMAT_DATE('%Y%m%d', CURRENT_DATE());
EXECUTE IMMEDIATE (
'''SELECT //Various stuff
FROM `''' || table_reference || '''` LIMIT 1000
''');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.