Search code examples
google-bigqueryexport-to-csv

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

  • 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(
    ...