Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions bigframes/core/compile/compiled.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
import bigframes_vendored.ibis.expr.datatypes as ibis_dtypes
import bigframes_vendored.ibis.expr.operations as ibis_ops
import bigframes_vendored.ibis.expr.types as ibis_types
import bigframes_vendored.sqlglot.expressions as sge
from google.cloud import bigquery
import pyarrow as pa

from bigframes.core import agg_expressions, rewrite
import bigframes.core.agg_expressions as ex_types
import bigframes.core.compile.googlesql
import bigframes.core.compile.ibis_compiler.aggregate_compiler as agg_compiler
import bigframes.core.compile.ibis_compiler.scalar_op_compiler as op_compilers
import bigframes.core.compile.ibis_types
Expand Down Expand Up @@ -82,13 +82,21 @@ def to_sql(
)

if order_by or limit or not is_noop_selection:
sql = ibis_bigquery.Backend().compile(ibis_table)
sql = (
bigframes.core.compile.googlesql.Select()
.from_(sql)
.select(selection_strings)
.sql()
)
# selections are (ref.id.sql, name) where ref.id.sql is escaped identifier
to_select = [
sge.Alias(
this=sge.to_identifier(src, quoted=False),
alias=sge.to_identifier(alias, quoted=True),
)
if src != alias
else sge.to_identifier(src, quoted=False)
for src, alias in selection_strings
]
# Use string formatting for FROM clause to avoid re-parsing potentially complex SQL (like ARRAY<STRUCT<...>>)
# that sqlglot might not handle perfectly when parsing BigQuery dialect strings.
select_sql = sge.Select().select(*to_select).sql(dialect="bigquery")
ibis_sql = ibis_bigquery.Backend().compile(ibis_table)
sql = f"{select_sql} FROM ({ibis_sql}) AS `t`"

# Single row frames may not have any ordering columns
if len(order_by) > 0:
Expand Down
61 changes: 0 additions & 61 deletions bigframes/core/compile/googlesql/__init__.py

This file was deleted.

25 changes: 0 additions & 25 deletions bigframes/core/compile/googlesql/abc.py

This file was deleted.

23 changes: 0 additions & 23 deletions bigframes/core/compile/googlesql/datatype.py

This file was deleted.

124 changes: 0 additions & 124 deletions bigframes/core/compile/googlesql/expression.py

This file was deleted.

32 changes: 0 additions & 32 deletions bigframes/core/compile/googlesql/function.py

This file was deleted.

Loading
Loading