Skip to content

Commit 8997d4d

Browse files
fix: Yield row count from read session if otherwise unknown (#2148)
1 parent 8514200 commit 8997d4d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

bigframes/session/read_api_execution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def process_page(page):
102102
if peek:
103103
batches = pyarrow_utils.truncate_pyarrow_iterable(batches, max_results=peek)
104104

105-
rows = node.source.n_rows
105+
rows = node.source.n_rows or session.estimated_row_count
106106
if peek and rows:
107107
rows = min(peek, rows)
108108

tests/system/small/test_dataframe.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,12 @@ def test_filter_df(scalars_dfs):
993993
assert_pandas_df_equal(bf_result, pd_result)
994994

995995

996+
def test_read_gbq_direct_to_batches_row_count(unordered_session):
997+
df = unordered_session.read_gbq("bigquery-public-data.usa_names.usa_1910_2013")
998+
iter = df.to_pandas_batches()
999+
assert iter.total_rows == 5552452
1000+
1001+
9961002
def test_df_to_pandas_batches(scalars_dfs):
9971003
scalars_df, scalars_pandas_df = scalars_dfs
9981004

0 commit comments

Comments
 (0)