Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,12 @@ def to_dataframe(self, dtypes=None):
pandas.DataFrame:
A data frame of all rows in the stream.
"""
warnings.warn(
"Retrieving DataFrames directly via google-cloud-bigquery-storage is deprecated. "
"Please use 'pandas_gbq.read_gbq()' or 'pandas_gbq.pandas.read_bigquery_stream_batches()'.",
PendingDeprecationWarning,
stacklevel=2,
)
if pandas is None:
raise ImportError(_PANDAS_REQUIRED)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import pandas
import pandas.testing
import pytest

from google.cloud.bigquery_storage import types

from .helpers import SCALAR_BLOCKS, SCALAR_COLUMN_NAMES, SCALAR_COLUMNS
Expand Down Expand Up @@ -700,3 +699,20 @@ def test_to_arrow_avro_consumes_first_page(class_under_test, mock_gapic_client):
# Since read_session was not provided, to_arrow() had to consume the first message
# to find out it was Avro. So offset should be 1.
assert reader._offset == 1


def test_to_dataframe_emits_pending_deprecation_warning(mut):
mock_parser = mock.Mock()
mock_message = mock.Mock()
mock_df = mock.Mock()
mock_parser.to_dataframe.return_value = mock_df

page = mut.ReadRowsPage(mock_parser, mock_message)
with pytest.warns(
PendingDeprecationWarning,
match="google-cloud-bigquery-storage is deprecated",
):
actual_df = page.to_dataframe()

assert actual_df == mock_df
mock_parser.to_dataframe.assert_called_once_with(mock_message, dtypes=None)
Loading