Skip to content

Commit 53978a8

Browse files
committed
refactor: fix remap variable errors for InNode
1 parent a0e1e50 commit 53978a8

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

bigframes/core/nodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1627,7 +1627,7 @@ class ResultNode(UnaryNode):
16271627
# TODO: CTE definitions
16281628

16291629
def _validate(self):
1630-
for ref, name in self.output_cols:
1630+
for ref, _ in self.output_cols:
16311631
assert ref.id in self.child.ids
16321632

16331633
@property

bigframes/core/rewrite/identifiers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ def remap_variables(
5757
new_root = root.transform_children(lambda node: remapped_children[node])
5858

5959
# Step 3: Transform the current node using the mappings from its children.
60+
# "reversed" is required for InNode so that in case of a duplicate column ID,
61+
# the left child's mapping is the one that's kept.
6062
downstream_mappings: dict[identifiers.ColumnId, identifiers.ColumnId] = {
61-
k: v for mapping in new_child_mappings for k, v in mapping.items()
63+
k: v for mapping in reversed(new_child_mappings) for k, v in mapping.items()
6264
}
6365
if isinstance(new_root, nodes.InNode):
6466
new_root = typing.cast(nodes.InNode, new_root)

tests/system/small/engines/test_join.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_engines_join_on_coerced_key(
5555
assert_equivalence_execution(result.node, REFERENCE_ENGINE, engine)
5656

5757

58-
@pytest.mark.parametrize("engine", ["polars", "bq"], indirect=True)
58+
@pytest.mark.parametrize("engine", ["polars", "bq", "bq-sqlglot"], indirect=True)
5959
@pytest.mark.parametrize("join_type", ["left", "inner", "right", "outer"])
6060
def test_engines_join_multi_key(
6161
scalars_array_value: array_value.ArrayValue,
@@ -90,7 +90,7 @@ def test_engines_cross_join(
9090
assert_equivalence_execution(result.node, REFERENCE_ENGINE, engine)
9191

9292

93-
@pytest.mark.parametrize("engine", ["polars", "bq"], indirect=True)
93+
@pytest.mark.parametrize("engine", ["polars", "bq", "bq-sqlglot"], indirect=True)
9494
@pytest.mark.parametrize(
9595
("left_key", "right_key"),
9696
[

tests/system/small/engines/test_slicing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
REFERENCE_ENGINE = polars_executor.PolarsExecutor()
2525

2626

27-
@pytest.mark.parametrize("engine", ["polars", "bq"], indirect=True)
27+
@pytest.mark.parametrize("engine", ["polars", "bq", "bq-sqlglot"], indirect=True)
2828
@pytest.mark.parametrize(
2929
("start", "stop", "step"),
3030
[

0 commit comments

Comments
 (0)