|
17 | 17 | from importlib import resources |
18 | 18 | import functools |
19 | 19 | import math |
20 | | -from typing import Any, cast, Dict, Iterator, List, Optional, Type |
| 20 | +from typing import Any, Dict, Iterator, List, Optional, Type |
21 | 21 | import uuid |
22 | 22 |
|
23 | 23 | import pandas as pd |
24 | 24 |
|
25 | 25 | import bigframes |
26 | | -import bigframes.core.blocks |
27 | 26 | import bigframes.display.html |
28 | | -import bigframes.session.execution_spec |
29 | 27 |
|
30 | 28 | # anywidget and traitlets are optional dependencies. We don't want the import of |
31 | 29 | # this module to fail if they aren't installed, though. Instead, we try to |
@@ -90,21 +88,11 @@ def __init__(self, dataframe: bigframes.dataframe.DataFrame): |
90 | 88 | # Respect display options for initial page size |
91 | 89 | self.page_size = bigframes.options.display.max_rows |
92 | 90 |
|
93 | | - # Force execution with explicit destination to get total_rows metadata |
94 | | - execute_result = dataframe._block.session._executor.execute( |
95 | | - dataframe._block.expr, |
96 | | - execution_spec=bigframes.session.execution_spec.ExecutionSpec( |
97 | | - ordered=True, promise_under_10gb=False |
98 | | - ), |
99 | | - ) |
100 | 91 | # The query issued by `to_pandas_batches()` already contains |
101 | 92 | # metadata about how many results there were. Use that to avoid |
102 | 93 | # doing an extra COUNT(*) query that `len(...)` would do. |
103 | | - self.row_count = execute_result.total_rows or 0 |
104 | | - self._batches = cast( |
105 | | - bigframes.core.blocks.PandasBatches, |
106 | | - execute_result.to_pandas_batches(page_size=self.page_size), |
107 | | - ) |
| 94 | + self._batches = self._dataframe.to_pandas_batches(page_size=self.page_size) |
| 95 | + self.row_count = self._batches.total_rows or 0 |
108 | 96 |
|
109 | 97 | self._set_table_html() |
110 | 98 | self._initial_load_complete = True |
@@ -198,19 +186,7 @@ def _cached_data(self) -> pd.DataFrame: |
198 | 186 |
|
199 | 187 | def _reset_batches_for_new_page_size(self) -> None: |
200 | 188 | """Reset the batch iterator when page size changes.""" |
201 | | - # Execute with explicit destination for consistency with __init__ |
202 | | - execute_result = self._dataframe._block.session._executor.execute( |
203 | | - self._dataframe._block.expr, |
204 | | - execution_spec=bigframes.session.execution_spec.ExecutionSpec( |
205 | | - ordered=True, promise_under_10gb=False |
206 | | - ), |
207 | | - ) |
208 | | - |
209 | | - # Create pandas batches from the ExecuteResult |
210 | | - self._batches = cast( |
211 | | - bigframes.core.blocks.PandasBatches, |
212 | | - execute_result.to_pandas_batches(page_size=self.page_size), |
213 | | - ) |
| 189 | + self._batches = self._dataframe.to_pandas_batches(page_size=self.page_size) |
214 | 190 |
|
215 | 191 | self._cached_batches = [] |
216 | 192 | self._batch_iter = None |
|
0 commit comments