File tree 3 files changed +8
-3
lines changed
3 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -1557,10 +1557,11 @@ def retrieve_repr_request_results(
1557
1557
Returns a tuple of the dataframe and the overall number of rows of the query.
1558
1558
"""
1559
1559
1560
+ # head caches full underlying expression, so row_count will be free after
1560
1561
head_result = self .session ._executor .head (self .expr , max_results )
1561
1562
count = self .session ._executor .get_row_count (self .expr )
1562
1563
1563
- arrow = self . session . _executor . execute ( self . expr ) .to_arrow_table ()
1564
+ arrow = head_result .to_arrow_table ()
1564
1565
df = io_pandas .arrow_to_pandas (arrow , schema = self .expr .schema )
1565
1566
self ._copy_index_to_pandas (df )
1566
1567
return df , count , head_result .query_job
Original file line number Diff line number Diff line change @@ -690,7 +690,6 @@ def _repr_html_(self) -> str:
690
690
if opts .repr_mode == "deferred" :
691
691
return formatter .repr_query_job (self ._compute_dry_run ())
692
692
693
- self ._cached ()
694
693
# TODO(swast): pass max_columns and get the true column count back. Maybe
695
694
# get 1 more column than we have requested so that pandas can add the
696
695
# ... for us?
Original file line number Diff line number Diff line change @@ -591,15 +591,19 @@ def test_join_repr(scalars_dfs_maybe_ordered):
591
591
assert actual == expected
592
592
593
593
594
- def test_repr_html_w_all_rows (scalars_dfs ):
594
+ def test_repr_html_w_all_rows (scalars_dfs , session ):
595
+ metrics = session ._metrics
595
596
scalars_df , _ = scalars_dfs
596
597
# get a pandas df of the expected format
597
598
df , _ = scalars_df ._block .to_pandas ()
598
599
pandas_df = df .set_axis (scalars_df ._block .column_labels , axis = 1 )
599
600
pandas_df .index .name = scalars_df .index .name
600
601
602
+ executions_pre = metrics .execution_count
601
603
# When there are 10 or fewer rows, the outputs should be identical except for the extra note.
602
604
actual = scalars_df .head (10 )._repr_html_ ()
605
+ executions_post = metrics .execution_count
606
+
603
607
with display_options .pandas_repr (bigframes .options .display ):
604
608
pandas_repr = pandas_df .head (10 )._repr_html_ ()
605
609
@@ -608,6 +612,7 @@ def test_repr_html_w_all_rows(scalars_dfs):
608
612
+ f"[{ len (pandas_df .index )} rows x { len (pandas_df .columns )} columns in total]"
609
613
)
610
614
assert actual == expected
615
+ assert (executions_post - executions_pre ) <= 2
611
616
612
617
613
618
def test_df_column_name_with_space (scalars_dfs ):
You can’t perform that action at this time.
0 commit comments