Skip to content

Commit accf797

Browse files
fix test issues and update snapshots
1 parent 49ddfdf commit accf797

File tree

51 files changed

+587
-879
lines changed

Some content is hidden

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

51 files changed

+587
-879
lines changed

bigframes/core/compile/sqlglot/sqlglot_ir.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def from_cte_ref(
154154
uid_gen: guid.SequentialUIDGenerator,
155155
) -> SQLGlotIR:
156156
table_expr = sge.Table(
157-
this=cte_ref,
157+
this=sql.identifier(cte_ref),
158158
)
159159
return cls(expr=table_expr, uid_gen=uid_gen)
160160

@@ -391,7 +391,7 @@ def with_ctes(
391391
sge_ctes = [
392392
sge.CTE(
393393
this=cte._as_select(),
394-
alias=cte_name,
394+
alias=sql.identifier(cte_name),
395395
)
396396
for cte_name, cte in ctes
397397
]
@@ -408,9 +408,9 @@ def resample(
408408
) -> SQLGlotIR:
409409
generate_array = sge.func(
410410
"GENERATE_ARRAY",
411-
start_expr._as_select(),
412-
stop_expr._as_select(),
413-
step_expr._as_select(),
411+
start_expr,
412+
stop_expr,
413+
step_expr,
414414
)
415415

416416
unnested_column_alias = sql.identifier(

bigframes/core/rewrite/as_sql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def _extract_ctes(root: nodes.BigFrameNode) -> nodes.BigFrameNode:
226226
topological_ctes = list(
227227
filter(lambda n: isinstance(n, nodes.CteNode), root.iter_nodes_topo())
228228
)
229-
cte_names = tuple(f"cte_{i}" for i in range(len(topological_ctes)))
229+
cte_names = tuple(f"bfcte_{i}" for i in range(len(topological_ctes)))
230230

231231
mapping = {
232232
cte_node: sql_nodes.SqlCteRefNode(cte_name, tuple(cte_node.fields))
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
WITH `bfcte_0` AS (
1+
SELECT
2+
FROM (
23
SELECT
3-
`int64_col`,
4-
`float64_col`
4+
`bfcol_2` AS `corr_col`
55
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
6-
), `bfcte_1` AS (
7-
SELECT
8-
CORR(`int64_col`, `float64_col`) AS `bfcol_2`
9-
FROM `bfcte_0`
10-
)
11-
SELECT
12-
`bfcol_2` AS `corr_col`
13-
FROM `bfcte_1`
6+
)
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
WITH `bfcte_0` AS (
1+
SELECT
2+
FROM (
23
SELECT
3-
`int64_col`,
4-
`float64_col`
4+
`bfcol_2` AS `cov_col`
55
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
6-
), `bfcte_1` AS (
7-
SELECT
8-
COVAR_SAMP(`int64_col`, `float64_col`) AS `bfcol_2`
9-
FROM `bfcte_0`
10-
)
11-
SELECT
12-
`bfcol_2` AS `cov_col`
13-
FROM `bfcte_1`
6+
)
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
WITH `bfcte_0` AS (
1+
SELECT
2+
FROM (
23
SELECT
3-
*
4+
`bfcol_32` AS `size`
45
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
5-
), `bfcte_1` AS (
6-
SELECT
7-
COUNT(1) AS `bfcol_32`
8-
FROM `bfcte_0`
9-
)
10-
SELECT
11-
`bfcol_32` AS `size`
12-
FROM `bfcte_1`
6+
)
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
WITH `bfcte_0` AS (
1+
SELECT
2+
FROM (
23
SELECT
3-
`int64_col`
4+
`bfcol_1` AS `int64_col`
45
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
5-
), `bfcte_1` AS (
6-
SELECT
7-
ARRAY_AGG(`int64_col` IGNORE NULLS ORDER BY `int64_col` IS NULL ASC, `int64_col` ASC) AS `bfcol_1`
8-
FROM `bfcte_0`
9-
)
10-
SELECT
11-
`bfcol_1` AS `int64_col`
12-
FROM `bfcte_1`
6+
)
Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
1-
WITH `bfcte_0` AS (
1+
SELECT
2+
FROM (
23
SELECT
3-
`string_col`
4+
`bfcol_1` AS `string_col`
45
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
5-
), `bfcte_1` AS (
6-
SELECT
7-
COALESCE(
8-
STRING_AGG(`string_col`, ','
9-
ORDER BY
10-
`string_col` IS NULL ASC,
11-
`string_col` ASC),
12-
''
13-
) AS `bfcol_1`
14-
FROM `bfcte_0`
15-
)
16-
SELECT
17-
`bfcol_1` AS `string_col`
18-
FROM `bfcte_1`
6+
)
Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
WITH `bfcte_0` AS (
1+
SELECT
2+
FROM (
23
SELECT
3-
`bool_col`,
4-
`int64_col`
4+
`bfcol_2` AS `bool_col`,
5+
`bfcol_3` AS `int64_col`
56
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
6-
), `bfcte_1` AS (
7-
SELECT
8-
COALESCE(LOGICAL_AND(`bool_col`), TRUE) AS `bfcol_2`,
9-
COALESCE(LOGICAL_AND(`int64_col` <> 0), TRUE) AS `bfcol_3`
10-
FROM `bfcte_0`
11-
)
12-
SELECT
13-
`bfcol_2` AS `bool_col`,
14-
`bfcol_3` AS `int64_col`
15-
FROM `bfcte_1`
7+
)
Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
WITH `bfcte_0` AS (
1+
SELECT
2+
FROM (
23
SELECT
3-
`bool_col`,
4-
`int64_col`
4+
`bfcol_2` AS `bool_col`,
5+
`bfcol_3` AS `int64_col`
56
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
6-
), `bfcte_1` AS (
7-
SELECT
8-
COALESCE(LOGICAL_OR(`bool_col`), FALSE) AS `bfcol_2`,
9-
COALESCE(LOGICAL_OR(`int64_col` <> 0), FALSE) AS `bfcol_3`
10-
FROM `bfcte_0`
11-
)
12-
SELECT
13-
`bfcol_2` AS `bool_col`,
14-
`bfcol_3` AS `int64_col`
15-
FROM `bfcte_1`
7+
)
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
WITH `bfcte_0` AS (
1+
SELECT
2+
FROM (
23
SELECT
3-
`int64_col`
4+
`bfcol_1` AS `int64_col`
45
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
5-
), `bfcte_1` AS (
6-
SELECT
7-
ANY_VALUE(`int64_col`) AS `bfcol_1`
8-
FROM `bfcte_0`
9-
)
10-
SELECT
11-
`bfcol_1` AS `int64_col`
12-
FROM `bfcte_1`
6+
)

0 commit comments

Comments
 (0)