Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit ce9fbb9

Browse files
amend selection compilation
1 parent e60f3ed commit ce9fbb9

File tree

50 files changed

+477
-570
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+477
-570
lines changed

bigframes/core/compile/sqlglot/sqlglot_ir.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,7 @@ def select(
166166
limit: typing.Optional[int] = None,
167167
) -> SQLGlotIR:
168168
# TODO: Explicitly insert CTEs into plan
169-
if isinstance(self.expr, sge.Select):
170-
new_expr = self._as_from_item()
171-
else:
172-
new_expr = sge.Select().from_(self.expr)
169+
new_expr = sge.Select().from_(self._as_from_item())
173170

174171
if len(sorting) > 0:
175172
new_expr = new_expr.order_by(*sorting)
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
(
1+
SELECT
2+
`bfcol_2` AS `corr_col`
3+
FROM (
24
SELECT
3-
`bfcol_2` AS `corr_col`
5+
CORR(`int64_col`, `float64_col`) AS `bfcol_2`
46
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
57
)
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
(
1+
SELECT
2+
`bfcol_2` AS `cov_col`
3+
FROM (
24
SELECT
3-
`bfcol_2` AS `cov_col`
5+
COVAR_SAMP(`int64_col`, `float64_col`) AS `bfcol_2`
46
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
57
)
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
(
1+
SELECT
2+
`bfcol_32` AS `size`
3+
FROM (
24
SELECT
3-
`bfcol_32` AS `size`
5+
COUNT(1) AS `bfcol_32`
46
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
57
)
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
(
1+
SELECT
2+
`bfcol_1` AS `int64_col`
3+
FROM (
24
SELECT
3-
`bfcol_1` AS `int64_col`
5+
ARRAY_AGG(`int64_col` IGNORE NULLS ORDER BY `int64_col` IS NULL ASC, `int64_col` ASC) AS `bfcol_1`
46
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
57
)
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
(
1+
SELECT
2+
`bfcol_1` AS `string_col`
3+
FROM (
24
SELECT
3-
`bfcol_1` AS `string_col`
5+
COALESCE(
6+
STRING_AGG(`string_col`, ','
7+
ORDER BY
8+
`string_col` IS NULL ASC,
9+
`string_col` ASC),
10+
''
11+
) AS `bfcol_1`
412
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
513
)
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
(
1+
SELECT
2+
`bfcol_2` AS `bool_col`,
3+
`bfcol_3` AS `int64_col`
4+
FROM (
25
SELECT
3-
`bfcol_2` AS `bool_col`,
4-
`bfcol_3` AS `int64_col`
6+
COALESCE(LOGICAL_AND(`bool_col`), TRUE) AS `bfcol_2`,
7+
COALESCE(LOGICAL_AND(`int64_col` <> 0), TRUE) AS `bfcol_3`
58
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
69
)
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
(
1+
SELECT
2+
`bfcol_2` AS `bool_col`,
3+
`bfcol_3` AS `int64_col`
4+
FROM (
25
SELECT
3-
`bfcol_2` AS `bool_col`,
4-
`bfcol_3` AS `int64_col`
6+
COALESCE(LOGICAL_OR(`bool_col`), FALSE) AS `bfcol_2`,
7+
COALESCE(LOGICAL_OR(`int64_col` <> 0), FALSE) AS `bfcol_3`
58
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
69
)
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
(
1+
SELECT
2+
`bfcol_1` AS `int64_col`
3+
FROM (
24
SELECT
3-
`bfcol_1` AS `int64_col`
5+
ANY_VALUE(`int64_col`) AS `bfcol_1`
46
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
57
)
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
(
1+
SELECT
2+
`bfcol_1` AS `q1`,
3+
`bfcol_2` AS `q2`,
4+
`bfcol_3` AS `q3`
5+
FROM (
26
SELECT
3-
`bfcol_1` AS `q1`,
4-
`bfcol_2` AS `q2`,
5-
`bfcol_3` AS `q3`
7+
APPROX_QUANTILES(`int64_col`, 4)[OFFSET(1)] AS `bfcol_1`,
8+
APPROX_QUANTILES(`int64_col`, 4)[OFFSET(2)] AS `bfcol_2`,
9+
APPROX_QUANTILES(`int64_col`, 4)[OFFSET(3)] AS `bfcol_3`
610
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
711
)

0 commit comments

Comments
 (0)