I would like to load data in to a table from a file in GCS using the bq load command. However, if the target table in BigQuery doesn't exist I don't want the bq load command to create it. I want an error message.
You can achieve this by using the --no-create-disposition flag with the bq load command. This flag prevents the creation of a new table if one doesn't already exist at the specified destination.
Here's how you can use it:
bq load --source_format=CSV --no-create-disposition your_dataset.your_table gs://your_bucket/your_data.csv ./your_schema.json
Thanks you for the response. I have tried adding the flag however I got the following error:
FATAL Flags parsing error: Unknown command line flag 'no-create-disposition'
Run 'bq.py help' to get help
My command was like this:
bq load --source_format=AVRO --no-create-disposition DataSet.TableName gs://MyBucket/FileName.avro
Please try:
bq load --source_format=AVRO \
--create_disposition=CREATE_NEVER \
DataSet.TableName \
gs://MyBucket/FileName.avro
I entered the command as follows:
bq load --source_format=AVRO --create_disposition=CREATE_NEVER DataSet.TableName gs://MyBucket/FileName.Avro
It is still giving the same error:
FATAL Flags parsing error: Unknown command line flag 'create_disposition'
Run 'bq.py help' to get help