|
38 | 38 | import bigframes.dtypes |
39 | 39 | import bigframes.exceptions as bfe |
40 | 40 | import bigframes.features |
41 | | -from bigframes.session import executor, local_scan_executor, read_api_execution |
| 41 | +from bigframes.session import ( |
| 42 | + executor, |
| 43 | + local_scan_executor, |
| 44 | + read_api_execution, |
| 45 | + semi_executor, |
| 46 | +) |
42 | 47 | import bigframes.session._io.bigquery as bq_io |
43 | 48 | import bigframes.session.metrics |
44 | 49 | import bigframes.session.planner |
@@ -123,21 +128,29 @@ def __init__( |
123 | 128 | *, |
124 | 129 | strictly_ordered: bool = True, |
125 | 130 | metrics: Optional[bigframes.session.metrics.ExecutionMetrics] = None, |
| 131 | + enable_polars_execution: bool = False, |
126 | 132 | ): |
127 | 133 | self.bqclient = bqclient |
128 | 134 | self.storage_manager = storage_manager |
129 | 135 | self.strictly_ordered: bool = strictly_ordered |
130 | 136 | self.cache: ExecutionCache = ExecutionCache() |
131 | 137 | self.metrics = metrics |
132 | 138 | self.bqstoragereadclient = bqstoragereadclient |
133 | | - # Simple left-to-right precedence for now |
134 | | - self._semi_executors = ( |
| 139 | + self._enable_polars_execution = enable_polars_execution |
| 140 | + self._semi_executors: Sequence[semi_executor.SemiExecutor] = ( |
135 | 141 | read_api_execution.ReadApiSemiExecutor( |
136 | 142 | bqstoragereadclient=bqstoragereadclient, |
137 | 143 | project=self.bqclient.project, |
138 | 144 | ), |
139 | 145 | local_scan_executor.LocalScanExecutor(), |
140 | 146 | ) |
| 147 | + if enable_polars_execution: |
| 148 | + from bigframes.session import polars_executor |
| 149 | + |
| 150 | + self._semi_executors = ( |
| 151 | + *self._semi_executors, |
| 152 | + polars_executor.PolarsExecutor(), |
| 153 | + ) |
141 | 154 |
|
142 | 155 | def to_sql( |
143 | 156 | self, |
@@ -542,8 +555,8 @@ def _execute_plan( |
542 | 555 | """Just execute whatever plan as is, without further caching or decomposition.""" |
543 | 556 | # First try to execute fast-paths |
544 | 557 | if not output_spec.require_bq_table: |
545 | | - for semi_executor in self._semi_executors: |
546 | | - maybe_result = semi_executor.execute(plan, ordered=ordered, peek=peek) |
| 558 | + for exec in self._semi_executors: |
| 559 | + maybe_result = exec.execute(plan, ordered=ordered, peek=peek) |
547 | 560 | if maybe_result: |
548 | 561 | return maybe_result |
549 | 562 |
|
|
0 commit comments