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

Commit 8db392e

Browse files
committed
refactor: fix pull_up_select disorder the columns of readtable nodes
1 parent a6aafaa commit 8db392e

File tree

8 files changed

+16
-17
lines changed
  • bigframes/core/rewrite
  • tests/unit/core/compile/sqlglot
    • aggregations/snapshots
    • snapshots/test_compile_explode
      • test_compile_explode_dataframe
      • test_compile_explode_series

8 files changed

+16
-17
lines changed

bigframes/core/rewrite/select_pullup.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,12 @@ def pull_up_source_ids(node: nodes.ReadTableNode) -> nodes.BigFrameNode:
5454
if all(id.sql == source_id for id, source_id in node.scan_list.items):
5555
return node
5656
else:
57-
source_ids = sorted(
58-
set(scan_item.source_id for scan_item in node.scan_list.items)
59-
)
6057
new_scan_list = nodes.ScanList.from_items(
6158
[
62-
nodes.ScanItem(identifiers.ColumnId(source_id), source_id)
63-
for source_id in source_ids
59+
nodes.ScanItem(
60+
identifiers.ColumnId(scan_item.source_id), scan_item.source_id
61+
)
62+
for scan_item in node.scan_list.items
6463
]
6564
)
6665
new_source = dataclasses.replace(node, scan_list=new_scan_list)

tests/unit/core/compile/sqlglot/aggregations/snapshots/test_binary_compiler/test_corr/out.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
WITH `bfcte_0` AS (
22
SELECT
3-
`float64_col`,
4-
`int64_col`
3+
`int64_col`,
4+
`float64_col`
55
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types`
66
), `bfcte_1` AS (
77
SELECT

tests/unit/core/compile/sqlglot/aggregations/snapshots/test_binary_compiler/test_cov/out.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
WITH `bfcte_0` AS (
22
SELECT
3-
`float64_col`,
4-
`int64_col`
3+
`int64_col`,
4+
`float64_col`
55
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types`
66
), `bfcte_1` AS (
77
SELECT

tests/unit/core/compile/sqlglot/aggregations/snapshots/test_nullary_compiler/test_size/out.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ WITH `bfcte_0` AS (
44
`bytes_col`,
55
`date_col`,
66
`datetime_col`,
7-
`duration_col`,
8-
`float64_col`,
97
`geography_col`,
108
`int64_col`,
119
`int64_too`,
1210
`numeric_col`,
11+
`float64_col`,
1312
`rowindex`,
1413
`rowindex_2`,
1514
`string_col`,
1615
`time_col`,
17-
`timestamp_col`
16+
`timestamp_col`,
17+
`duration_col`
1818
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types`
1919
), `bfcte_1` AS (
2020
SELECT

tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_mean/out.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
WITH `bfcte_0` AS (
22
SELECT
33
`bool_col`,
4-
`duration_col`,
54
`int64_col`,
5+
`duration_col`,
66
`int64_col` AS `bfcol_6`,
77
`bool_col` AS `bfcol_7`,
88
`duration_col` AS `bfcol_8`

tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_std/out.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
WITH `bfcte_0` AS (
22
SELECT
33
`bool_col`,
4-
`duration_col`,
54
`int64_col`,
5+
`duration_col`,
66
`int64_col` AS `bfcol_6`,
77
`bool_col` AS `bfcol_7`,
88
`duration_col` AS `bfcol_8`

tests/unit/core/compile/sqlglot/snapshots/test_compile_explode/test_compile_explode_dataframe/out.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
WITH `bfcte_0` AS (
22
SELECT
3-
`int_list_col`,
43
`rowindex`,
4+
`int_list_col`,
55
`string_list_col`
66
FROM `bigframes-dev`.`sqlglot_test`.`repeated_types`
77
), `bfcte_1` AS (

tests/unit/core/compile/sqlglot/snapshots/test_compile_explode/test_compile_explode_series/out.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
WITH `bfcte_0` AS (
22
SELECT
3-
`int_list_col`,
4-
`rowindex`
3+
`rowindex`,
4+
`int_list_col`
55
FROM `bigframes-dev`.`sqlglot_test`.`repeated_types`
66
), `bfcte_1` AS (
77
SELECT

0 commit comments

Comments
 (0)