File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
tests/system/small/session Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -345,6 +345,8 @@ def _read_gbq_colab(
345
345
dry_run = True ,
346
346
)
347
347
_set_default_session_location_if_possible_deferred_query (create_query )
348
+ if not config .options .bigquery ._session_started :
349
+ config .options .bigquery .enable_polars_execution = True
348
350
349
351
return global_session .with_default_session (
350
352
bigframes .session .Session ._read_gbq_colab ,
Original file line number Diff line number Diff line change 19
19
import pandas .testing
20
20
import pytest
21
21
22
+ import bigframes
23
+ import bigframes .pandas
24
+
25
+ pytest .importorskip ("polars" )
26
+
22
27
23
28
def test_read_gbq_colab_to_pandas_batches_preserves_order_by (maybe_ordered_session ):
24
29
# This query should return enough results to be too big to fit in a single
@@ -59,6 +64,31 @@ def test_read_gbq_colab_to_pandas_batches_preserves_order_by(maybe_ordered_sessi
59
64
assert executions_after == executions_before_python == executions_before_sql + 1
60
65
61
66
67
+ def test_read_gbq_colab_fresh_session_is_hybrid ():
68
+ bigframes .close_session ()
69
+ df = bigframes .pandas ._read_gbq_colab (
70
+ """
71
+ SELECT
72
+ name,
73
+ SUM(number) AS total
74
+ FROM
75
+ `bigquery-public-data.usa_names.usa_1910_2013`
76
+ WHERE state LIKE 'W%'
77
+ GROUP BY name
78
+ ORDER BY total DESC
79
+ LIMIT 300
80
+ """
81
+ )
82
+ session = df ._session
83
+ executions_before_python = session ._metrics .execution_count
84
+ result = df .sort_values ("name" ).peek (100 )
85
+ executions_after = session ._metrics .execution_count
86
+
87
+ assert len (result ) == 100
88
+ assert session ._executor ._enable_polars_execution is True # type: ignore
89
+ assert executions_after == executions_before_python == 1
90
+
91
+
62
92
def test_read_gbq_colab_peek_avoids_requery (maybe_ordered_session ):
63
93
executions_before_sql = maybe_ordered_session ._metrics .execution_count
64
94
df = maybe_ordered_session ._read_gbq_colab (
You can’t perform that action at this time.
0 commit comments