Skip to content

ENH: Improve the error message in to_gbq when schema does not match #11359 #11401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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