-
Notifications
You must be signed in to change notification settings - Fork 125
BUG: resolve divide by 0 error when uploading empty dataframe #252
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
Changes from 10 commits
42ccab2
3864d46
272aa7b
8bfde50
59a7950
87ae125
02c897a
a9ec115
922707c
1fe7c13
d62c36e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -924,6 +924,28 @@ def test_upload_data(self, project_id): | |
) | ||
assert result["num_rows"][0] == test_size | ||
|
||
def test_upload_empty_data(self, project_id): | ||
test_id = "data_with_0_rows" | ||
test_size = 0 | ||
df = DataFrame() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like we might have an additional problem when the DataFrame contains no columns. In the conda build (https://circleci.com/gh/tswast/pandas-gbq/276) I'm getting:
Since we still create a table in pandas-gbq before running the load job, we can probably avoid doing the load job altogether when a DataFrame contains no rows. |
||
|
||
gbq.to_gbq( | ||
df, | ||
self.destination_table + test_id, | ||
project_id, | ||
credentials=self.credentials, | ||
) | ||
|
||
result = gbq.read_gbq( | ||
"SELECT COUNT(*) AS num_rows FROM {0}".format( | ||
self.destination_table + test_id | ||
), | ||
project_id=project_id, | ||
credentials=self.credentials, | ||
dialect="legacy", | ||
) | ||
assert result["num_rows"][0] == test_size | ||
|
||
def test_upload_data_if_table_exists_fail(self, project_id): | ||
test_id = "2" | ||
test_size = 10 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should still be in 0.10.0!