You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BigQuery: "Failed to parse JSON: No active field found" when using load_table_from_json() #9203
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:
Actually, the type of test_ndjson is incorrect. It should be an iterable of dictionaries (docs). Changing test_ndjson to the following will work:
test_ndjson= [{"name": "bob"}]
@tswast I suppose it is reasonable to expect that passing in a JSON string to the method should work, too - let's add support for that?
(re-classifying as feature request, and will update the description if confirmed)
This feels a bit redundant with the load_table_from_file method, since really we just want to pass the bytes through to the resumable upload in this case. Maybe we need a load_table_from_string / load_table_from_bytes method?
Have there been feature requests for this in the past?
Not sure if we really need a *_from_string version of the method, since it is straightforward to wrap string data into a binary file-like object, and pass it to load_table_from_file()...
Activity
plamut commentedon Sep 11, 2019
Confirmed, I was able to reproduce the issue with the posted code (thanks @jacques- ).
plamut commentedon Sep 11, 2019
Actually, the type of
test_ndjsonis incorrect. It should be an iterable of dictionaries (docs). Changingtest_ndjsonto the following will work:@tswast I suppose it is reasonable to expect that passing in a JSON string to the method should work, too - let's add support for that?
(re-classifying as feature request, and will update the description if confirmed)
tswast commentedon Sep 12, 2019
This feels a bit redundant with the
load_table_from_filemethod, since really we just want to pass the bytes through to the resumable upload in this case. Maybe we need aload_table_from_string/load_table_from_bytesmethod?plamut commentedon Sep 12, 2019
Have there been feature requests for this in the past?
Not sure if we really need a
*_from_stringversion of the method, since it is straightforward to wrap string data into a binary file-like object, and pass it toload_table_from_file()...tswast commentedon Sep 12, 2019
I agree that
*_from_stringis probably not necessary. A few code samples on how to wrap a string in a BytesIO / StringIO object would likely suffice.