Skip to content

Commit 8a897cd

Browse files
committed
Merge remote-tracking branch 'origin/tswast-st-regionstats' into tswast-st-regionstats
2 parents a0d8e28 + 924dd2c commit 8a897cd

File tree

7 files changed

+73
-7
lines changed

7 files changed

+73
-7
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)

bigframes/functions/function_typing.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,22 @@ class UnsupportedTypeError(ValueError):
6060
def __init__(self, type_, supported_types):
6161
self.type = type_
6262
self.supported_types = supported_types
63+
64+
types_to_format = supported_types
65+
if isinstance(supported_types, dict):
66+
types_to_format = supported_types.keys()
67+
68+
supported_types_str = ", ".join(
69+
sorted(
70+
[
71+
getattr(supported, "__name__", supported)
72+
for supported in types_to_format
73+
]
74+
)
75+
)
76+
6377
super().__init__(
64-
f"'{type_}' must be one of the supported types ({supported_types}) "
78+
f"'{getattr(type_, '__name__', type_)}' must be one of the supported types ({supported_types_str}) "
6579
"or a list of one of those types."
6680
)
6781

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
[

tests/system/small/functions/test_remote_function.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1646,7 +1646,7 @@ def func_tuple(x):
16461646

16471647
with pytest.raises(
16481648
ValueError,
1649-
match=r"'typing\.Sequence\[int\]' must be one of the supported types",
1649+
match=r"must be one of the supported types",
16501650
):
16511651
bff.remote_function(
16521652
input_types=int,
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import datetime
16+
import decimal
17+
18+
import pytest
19+
20+
from bigframes.functions import function_typing
21+
22+
23+
def test_unsupported_type_error_init_with_dict():
24+
err = function_typing.UnsupportedTypeError(
25+
decimal.Decimal, {int: "INT64", float: "FLOAT64"}
26+
)
27+
28+
message = str(err)
29+
30+
assert "Decimal" in message
31+
assert "float, int" in message
32+
33+
34+
def test_unsupported_type_error_init_with_set():
35+
err = function_typing.UnsupportedTypeError(decimal.Decimal, {int, float})
36+
37+
message = str(err)
38+
39+
assert "Decimal" in message
40+
assert "float, int" in message
41+
42+
43+
def test_sdk_type_from_python_type_raises_unsupported_type_error():
44+
with pytest.raises(function_typing.UnsupportedTypeError) as excinfo:
45+
function_typing.sdk_type_from_python_type(datetime.datetime)
46+
47+
message = str(excinfo.value)
48+
49+
assert "datetime" in message
50+
assert "bool, bytes, float, int, str" in message

0 commit comments

Comments
 (0)