Skip to content

Commit 4c968b7

Browse files
disable hybrid engine unless flag set
1 parent 83eeb97 commit 4c968b7

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

bigframes/pandas/io/api.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ def _read_gbq_colab( # type: ignore[overload-overlap]
279279
*,
280280
pyformat_args: Optional[Dict[str, Any]] = ...,
281281
dry_run: Literal[False] = ...,
282+
use_hybrid_engine: bool = ...,
282283
) -> bigframes.dataframe.DataFrame:
283284
...
284285

@@ -289,6 +290,7 @@ def _read_gbq_colab(
289290
*,
290291
pyformat_args: Optional[Dict[str, Any]] = ...,
291292
dry_run: Literal[True] = ...,
293+
use_hybrid_engine: bool = ...,
292294
) -> pandas.Series:
293295
...
294296

@@ -298,6 +300,7 @@ def _read_gbq_colab(
298300
*,
299301
pyformat_args: Optional[Dict[str, Any]] = None,
300302
dry_run: bool = False,
303+
use_hybrid_engine: bool = False,
301304
) -> bigframes.dataframe.DataFrame | pandas.Series:
302305
"""A Colab-specific version of read_gbq.
303306
@@ -312,7 +315,9 @@ def _read_gbq_colab(
312315
dry_run (bool):
313316
If True, estimates the query results size without returning data.
314317
The return will be a pandas Series with query metadata.
315-
318+
use_hybrid_engine (bool):
319+
If True, and session not started, new session started will use
320+
hybrid execution which pushes some execution to local cpu.
316321
Returns:
317322
Union[bigframes.dataframe.DataFrame, pandas.Series]:
318323
A BigQuery DataFrame if `dry_run` is False, otherwise a pandas Series.
@@ -345,7 +350,7 @@ def _read_gbq_colab(
345350
dry_run=True,
346351
)
347352
_set_default_session_location_if_possible_deferred_query(create_query)
348-
if not config.options.bigquery._session_started:
353+
if use_hybrid_engine and not config.options.bigquery._session_started:
349354
config.options.bigquery.enable_polars_execution = True
350355

351356
return global_session.with_default_session(

tests/system/small/session/test_read_gbq_colab.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ def test_read_gbq_colab_fresh_session_is_hybrid():
7777
GROUP BY name
7878
ORDER BY total DESC
7979
LIMIT 300
80-
"""
80+
""",
81+
use_hybrid_engine=True,
8182
)
8283
session = df._session
8384
executions_before_python = session._metrics.execution_count

0 commit comments

Comments
 (0)