diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 60861dea..3b43ccd3 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -6,6 +6,8 @@ Changelog 0.10.0 / TBD ------------ +- This fixes a bug where pandas-gbq could not upload an empty database. (:issue:`237`) + Dependency updates ~~~~~~~~~~~~~~~~~~ @@ -235,4 +237,4 @@ Initial release of transfered code from `pandas `__ -- :func:`read_gbq` now stores ``INTEGER`` columns as ``dtype=object`` if they contain ``NULL`` values. Otherwise they are stored as ``int64``. This prevents precision lost for integers greather than 2**53. Furthermore ``FLOAT`` columns with values above 10**4 are no longer casted to ``int64`` which also caused precision loss `pandas-GH#14064 `__, and `pandas-GH#14305 `__ +- :func:`read_gbq` now stores ``INTEGER`` columns as ``dtype=object`` if they contain ``NULL`` values. Otherwise they are stored as ``int64``. This prevents precision lost for integers greather than 2**53. Furthermore ``FLOAT`` columns with values above 10**4 are no longer casted to ``int64`` which also caused precision loss `pandas-GH#14064 `__, and `pandas-GH#14305 `__ \ No newline at end of file diff --git a/pandas_gbq/gbq.py b/pandas_gbq/gbq.py index 13d65669..b59c3f94 100644 --- a/pandas_gbq/gbq.py +++ b/pandas_gbq/gbq.py @@ -518,8 +518,8 @@ def load_data( chunks = tqdm.tqdm(chunks) for remaining_rows in chunks: logger.info( - "\rLoad is {0}% Complete".format( - ((total_rows - remaining_rows) * 100) / total_rows + "\r{} out of {} rows loaded.".format( + total_rows - remaining_rows, total_rows ) ) except self.http_error as ex: diff --git a/tests/system/test_gbq.py b/tests/system/test_gbq.py index 82753a38..2153926d 100644 --- a/tests/system/test_gbq.py +++ b/tests/system/test_gbq.py @@ -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() + + 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