Skip to content
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

BigQuery: Add support for BigQuery Storage API Arrow format in to_dataframe and to_arrow. #8551

Merged
merged 20 commits into from
Jul 12, 2019
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Set streams in mock session.
  • Loading branch information
tswast committed Jul 12, 2019
commit a88690e732c881ff7e8b842ba1c09455eb6b5dde
7 changes: 4 additions & 3 deletions bigquery/tests/unit/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1721,7 +1721,6 @@ def test_to_arrow_w_bqstorage(self):
{"name": "/projects/proj/dataset/dset/tables/tbl/streams/5678"},
]
session = bigquery_storage_v1beta1.types.ReadSession(streams=streams)
session = bigquery_storage_v1beta1.types.ReadSession()
arrow_schema = pyarrow.schema(
[
pyarrow.field("colA", pyarrow.int64()),
Expand All @@ -1738,6 +1737,8 @@ def test_to_arrow_w_bqstorage(self):

mock_rows = mock.create_autospec(reader.ReadRowsIterable)
mock_rowstream.rows.return_value = mock_rows
expected_num_rows = 2
expected_num_columns = 3
page_items = [
pyarrow.array([1, -1]),
pyarrow.array([2.0, 4.0]),
Expand Down Expand Up @@ -1769,14 +1770,14 @@ def test_to_arrow_w_bqstorage(self):
actual_tbl = row_iterator.to_arrow(bqstorage_client=bqstorage_client)

# Are the columns in the expected order?
self.assertEqual(actual_tbl.num_columns, 3)
self.assertEqual(actual_tbl.num_columns, expected_num_columns)
self.assertEqual(actual_tbl.schema[0].name, "colA")
self.assertEqual(actual_tbl.schema[1].name, "colC")
self.assertEqual(actual_tbl.schema[2].name, "colB")

# Have expected number of rows?
total_pages = len(streams) * len(mock_pages)
total_rows = len(page_items) * total_pages
total_rows = expected_num_rows * total_pages
self.assertEqual(actual_tbl.num_rows, total_rows)

@unittest.skipIf(pyarrow is None, "Requires `pyarrow`")
Expand Down