Closed
Description
On Mac (Python 3.7.4 & google-cloud-bigquery==1.19.0) I'm using the following code:
from google.cloud import bigquery
test_ndjson = '{"name": "bob"}'
client = bigquery.Client()
table_ref = client.dataset('my_ds').table('test')
job_config = bigquery.LoadJobConfig()
job_config.write_disposition = bigquery.WriteDisposition.WRITE_TRUNCATE
job_config.source_format = bigquery.SourceFormat.NEWLINE_DELIMITED_JSON
job_config.autodetect = True
job = client.load_table_from_json(test_ndjson, table_ref, job_config=job_config)
job.result() # Waits for table load to complete.
I get:
google.api_core.exceptions.BadRequest: 400 Error while reading data, error message: Failed to parse JSON: No active field found.; ParsedString returned false
When I do exactly the same thing using the bq command it works as expected:
echo '{"name": "bob"}' > data.json
bq load --apilog '' --source_format=NEWLINE_DELIMITED_JSON --autodetect=True myproject\:my_ds.test ./data.json