Skip to content

Commit 90e277e

Browse files
refactor: Streamline executor paths (#1708)
1 parent 2b3a45f commit 90e277e

File tree

9 files changed

+186
-210
lines changed

9 files changed

+186
-210
lines changed

bigframes/core/array_value.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -172,33 +172,6 @@ def order_ambiguous(self) -> bool:
172172
def supports_fast_peek(self) -> bool:
173173
return bigframes.core.tree_properties.can_fast_peek(self.node)
174174

175-
def as_cached(
176-
self: ArrayValue,
177-
cache_table: google.cloud.bigquery.Table,
178-
ordering: Optional[orderings.RowOrdering],
179-
) -> ArrayValue:
180-
"""
181-
Replace the node with an equivalent one that references a table where the value has been materialized to.
182-
"""
183-
table = nodes.GbqTable.from_table(cache_table)
184-
source = nodes.BigqueryDataSource(
185-
table, ordering=ordering, n_rows=cache_table.num_rows
186-
)
187-
# Assumption: GBQ cached table uses field name as bq column name
188-
scan_list = nodes.ScanList(
189-
tuple(
190-
nodes.ScanItem(field.id, field.dtype, field.id.name)
191-
for field in self.node.fields
192-
)
193-
)
194-
node = nodes.CachedTableNode(
195-
original_node=self.node,
196-
source=source,
197-
table_session=self.session,
198-
scan_list=scan_list,
199-
)
200-
return ArrayValue(node)
201-
202175
def get_column_type(self, key: str) -> bigframes.dtypes.Dtype:
203176
return self.schema.get_type(key)
204177

bigframes/core/compile/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@
1313
# limitations under the License.
1414
from __future__ import annotations
1515

16-
from bigframes.core.compile.api import SQLCompiler, test_only_ibis_inferred_schema
16+
from bigframes.core.compile.api import test_only_ibis_inferred_schema
17+
from bigframes.core.compile.compiler import compile_sql
18+
from bigframes.core.compile.configs import CompileRequest, CompileResult
1719

1820
__all__ = [
19-
"SQLCompiler",
2021
"test_only_ibis_inferred_schema",
22+
"compile_sql",
23+
"CompileRequest",
24+
"CompileResult",
2125
]

bigframes/core/compile/api.py

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,13 @@
1313
# limitations under the License.
1414
from __future__ import annotations
1515

16-
from typing import Optional, Sequence, Tuple, TYPE_CHECKING
17-
18-
import google.cloud.bigquery as bigquery
16+
from typing import TYPE_CHECKING
1917

2018
from bigframes.core import rewrite
21-
from bigframes.core.compile import compiler, configs
19+
from bigframes.core.compile import compiler
2220

2321
if TYPE_CHECKING:
2422
import bigframes.core.nodes
25-
import bigframes.core.ordering
26-
27-
28-
class SQLCompiler:
29-
def compile(
30-
self,
31-
node: bigframes.core.nodes.BigFrameNode,
32-
*,
33-
ordered: bool = True,
34-
limit: Optional[int] = None,
35-
) -> str:
36-
"""Compile node into sql where rows are sorted with ORDER BY."""
37-
request = configs.CompileRequest(node, sort_rows=ordered, peek_count=limit)
38-
return compiler.compile_sql(request).sql
39-
40-
def compile_raw(
41-
self,
42-
node: bigframes.core.nodes.BigFrameNode,
43-
) -> Tuple[
44-
str, Sequence[bigquery.SchemaField], bigframes.core.ordering.RowOrdering
45-
]:
46-
"""Compile node into sql that exposes all columns, including hidden ordering-only columns."""
47-
request = configs.CompileRequest(
48-
node, sort_rows=False, materialize_all_order_keys=True
49-
)
50-
result = compiler.compile_sql(request)
51-
assert result.row_order is not None
52-
return result.sql, result.sql_schema, result.row_order
5323

5424

5525
def test_only_ibis_inferred_schema(node: bigframes.core.nodes.BigFrameNode):

0 commit comments

Comments
 (0)