BigQuery bq command - load only if table is empty or doesn't exist

I am executing a load command with bq, for example:

bq load ds.table gs://mybucket/data.csv dt:TIMESTAMP,f1:INTEGER

I would like to load data only if the table is empty or doesn't exist.

Is it possible?

EDIT:

Basically, I need the WRITE_EMPTY API parameter via the bq command line tool:

https://cloud.google.com/bigquery/docs/reference/v2/jobs#configuration.load.writeDisposition

If the table already exists and contains data, the job returns a "duplicate" error.

+3


source to share


2 answers


If you run check bq.py, which has the source code for the BigQuery CLI, you will find that the _Load () method does not implement an option for the WRITE_EMPTY API parameter. This is either the default WRITE_APPEND or the optional WRITE_TRUNCATE parameter.



As you pointed out, the API supports WRITE_EMPTY - if you want to see this as an option in the CLI, you can submit a feature request at https://code.google.com/p/google-bigquery/issues/list?q=label:Feature- Request

+3


source


You can use the BQ command line tool.

Get table information

bq show <project_id>:<dataset_id>.<table_id>

      



List of tables

 bq ls [project_id:][dataset_id]

      

+3


source







All Articles