samxitij
samxitij

Reputation: 21

Getting error when loading JSON from GCS

I am trying to load schema and data from GCS as JSON files. I am using command line for this purpose.

bq load --source_format=NEWLINE_DELIMITED_JSON --schema=gs://1samtest/JSONSample/personsDataSchema.json SSData.persons_data gs://1samtest/JSONSample/personsData.json

But I get this error:

//1SAMTEST/JSONSAMPLE/PERSONSDATASCHEMA.JSON is not a valid value

But when I change all paths to my local machine it works completely file. But don't know why its getting error for json.

If I run like below after creating table in BigQuery it works fine.

bq load  --source_format=NEWLINE_DELIMITED_JSON SSData.persons_data  "gs://1samtest/JSONSample/personsData.json"

Upvotes: 2

Views: 2073

Answers (1)

Graham Polley
Graham Polley

Reputation: 14791

The schema flag/param doesn't support URIs for GCS i.e. using gs://...

bq load --help

The [destination_table] is the fully-qualified table name of table to create, or append to if the table already exists.

The [source] argument can be a path to a single local file, or a comma-separated list of URIs.

The [schema] argument should be either the name of a JSON file or a text schema. This schema should be omitted if the table already has one.

Only the source flag/param (i.e. the data) can be used with GCS URIs.

Upvotes: 2

Related Questions