问题
In BigQuery, I can compose a query and then set a destination table under More > Query Settings. This works as expected for queries without variables, for example:
SELECT * FROM foo.bar WHERE PARSE_TIMESTAMP("%a, %d %b %Y %X %z", date_created) > '2020-01-01 00:00:00';
However, when I try to replace that formatting string with a variable, suddenly the options to set a destination table do not exist under More > Query Settings. For example:
DECLARE date_format STRING DEFAULT "%a, %d %b %Y %X %z";
SELECT * FROM foo.bar WHERE PARSE_TIMESTAMP(date_format, date_created) > '2020-01-01 00:00:00';
Additionally, even when I try to schedule the second query, I do not have an option to set a destination table.
Is this behavior expected? Is it documented anywhere? I have been unable to find an explanation.
回答1:
It is not because of use of parameters per se! But rather limitation of scripting.
So, YES, it is expected - when you use scripting you cannot use destination otherwise you will be getting error
If you need to get result into some table - just use INSERT INTO or any other relevant DML/DDL within your script
来源:https://stackoverflow.com/questions/60128699/why-doesnt-bigquery-ui-allow-setting-a-destination-table-if-a-query-uses-variab