'Scheduling data extract from Google BigQuery using export data

I am trying to schedule monthly data exports in Google bigquery using query scheduler. This is how my query looks atm:

export data options(
uri='gs://bucket_name/Test*.csv',
format='CSV',
header=true,
overwrite=true,
field_delimiter=';') as
select id from `project.database.table`;

This works perfectly when I run the query but fails when I save this as a scheduled query (Error: Cannot set destination table in jobs with EXPORT statement)

I cannot use the scheduler without specifying a result table. Is there a way to get around this limitation?



Solution 1:[1]

This sounds like a bug that BigQuery is requiring setting up a destination table for EXPORT DATA query. Please try this workaround while waiting for a fix:

-- Add this line for your query to be treated as a script
declare unused STRING;

export data options(
...

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1