Skip to content

Inability to cast int to string when appending data to table using load_table_from_json #906

@Nathan-Nesbitt

Description

@Nathan-Nesbitt

Issue

I can append this data using the stream functionality, but with a job it fails to convert properly. Is this an error on my part or a bug?

Environment details

  • OS type and version: Ubuntu 20.04.2 LTS
  • Python version: 3.9
  • pip version: 21.1.3
  • google-cloud-bigquery version: 1.24.0

Steps to reproduce

  1. Run the following query which works in a stream in a job

Code example

row = {'id': '781263812376123', ...}
table = client.get_table(table)
job_config = LoadJobConfig(table.schema, write_disposition=WriteDisposition.WRITE_APPEND)
job = client.load_table_from_json([row], destination=table, job_config=job_config)

Stack trace

ebapp_1  |   File "<REMOVED>", line 130, in insert_rows_batch
webapp_1  |     job.result()
webapp_1  |     │   └ <function _AsyncJob.result at 0x7fd294afd820>
webapp_1  |     └ <google.cloud.bigquery.job.LoadJob object at 0x7fd28ae04160>
webapp_1  | 
webapp_1  |   File "/home/python/lib/python3.8/site-packages/google/cloud/bigquery/job.py", line 818, in result
webapp_1  |     return super(_AsyncJob, self).result(timeout=timeout)
webapp_1  |                  │          │                    └ None
webapp_1  |                  │          └ <google.cloud.bigquery.job.LoadJob object at 0x7fd28ae04160>
webapp_1  |                  └ <class 'google.cloud.bigquery.job._AsyncJob'>
webapp_1  |   File "/home/python/lib/python3.8/site-packages/google/api_core/future/polling.py", line 130, in result
webapp_1  |     raise self._exception
webapp_1  |           │    └ BadRequest('Error while reading data, error message: JSON table encountered too many errors, giving up. Rows: 1; errors: 1. P...
webapp_1  |           └ <google.cloud.bigquery.job.LoadJob object at 0x7fd28ae04160>
webapp_1  | 
webapp_1  | google.api_core.exceptions.BadRequest: 400 Error while reading data, error message: JSON table encountered too many errors, giving up. Rows: 1; errors: 1. Please look into the errors[] collection for more details.

Which leads to

'Error while reading data, error message: JSON parsing error in row starting at position 0: Could not convert value to string. Field: id; Value: 781263812376123'

Metadata

Metadata

Assignees

Labels

api: bigqueryIssues related to the googleapis/python-bigquery API.priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions