Improve the BigQuery streaming insert failure message · Issue #11285 · pandas-dev/pandas (original) (raw)
The error message shown when a BigQuery streaming insert fails could be improved by adding the location field.
Code to reproduce:
from datetime import datetime
from pandas import DataFrame
from pandas.io import gbq
import pytz
test_timestamp = datetime.now(pytz.timezone('US/Arizona'))
bad_df = DataFrame({'bools': [False, False], 'flts': [0.0, 1.0], 'ints': [0, '1'], 'strs': ['a', 1],
'times': [test_timestamp, test_timestamp]}, index=range(2))
gbq.to_gbq(bad_df, destination_table, project_id, verbose=True,if_exists='replace')
Output:
Streaming Insert is 100% Complete
Error at Row: 0, Reason: invalid, Message: Could not convert value to string
Error at Row: 1, Reason: invalid, Message: Could not convert value to string
Proposed output:
Streaming Insert is 100% Complete
Error at Row: 0, Reason: invalid, Location: Field:ints, Message: Could not convert value to string
Error at Row: 1, Reason: invalid, Location: Field:strs, Message: Could not convert value to string