Skip to content

Commit

Permalink
Merge pull request #11401 from parthea/bq-improve-schema-error-msg
Browse files Browse the repository at this point in the history
ENH: Improve the error message in to_gbq when schema does not match #11359
  • Loading branch information
jreback committed Oct 21, 2015
2 parents 1aa6cd4 + 21494bb commit b09b84e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.17.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Other Enhancements

- ``pd.read_*`` functions can now also accept :class:`python:pathlib.Path`, or :class:`py:py._path.local.LocalPath`
objects for the ``filepath_or_buffer`` argument. (:issue:`11033`)
- Improve the error message displayed in :func:`pandas.io.gbq.to_gbq` when the DataFrame does not match the schema of the destination table (:issue:`11359`)

.. _whatsnew_0171.api:

Expand Down
3 changes: 2 additions & 1 deletion pandas/io/gbq.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,8 @@ def to_gbq(dataframe, destination_table, project_id, chunksize=10000,
connector.delete_and_recreate_table(dataset_id, table_id, table_schema, verbose)
elif if_exists == 'append':
if not connector.verify_schema(dataset_id, table_id, table_schema):
raise InvalidSchema("The schema of the destination table does not match")
raise InvalidSchema("Please verify that the column order, structure and data types in the DataFrame "
"match the schema of the destination table.")
else:
table.create(table_id, table_schema)

Expand Down

0 comments on commit b09b84e

Please sign in to comment.