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

Commit 93c2689

Browse files
committed
track explode node and defined ignored nodes
1 parent 783e286 commit 93c2689

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

bigframes/core/logging/data_types.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@
2020
from bigframes.core import agg_expressions, bigframe_node, expression, nodes
2121
from bigframes.core.rewrite import schema_binding
2222

23+
IGNORED_NODES = (
24+
nodes.SelectionNode,
25+
nodes.ReadLocalNode,
26+
nodes.ReadTableNode,
27+
nodes.ConcatNode,
28+
nodes.RandomSampleNode,
29+
nodes.FromRangeNode,
30+
nodes.PromoteOffsetsNode,
31+
nodes.ReversedNode,
32+
nodes.SliceNode,
33+
nodes.ResultNode,
34+
)
35+
2336

2437
def encode_type_refs(root: bigframe_node.BigFrameNode) -> str:
2538
return f"{root.reduce_up(_encode_type_refs_from_node):x}"
@@ -42,9 +55,6 @@ def _encode_type_refs_from_node(
4255
curr_result = curr_result | _encode_type_refs_from_expr(
4356
assignment[0], node.child
4457
)
45-
elif isinstance(node, nodes.SelectionNode):
46-
# Do nothing
47-
pass
4858
elif isinstance(node, nodes.OrderByNode):
4959
for by in node.by:
5060
curr_result = curr_result | _encode_type_refs_from_expr(
@@ -75,6 +85,17 @@ def _encode_type_refs_from_node(
7585
curr_result = curr_result | _encode_type_refs_from_expr(
7686
col_def.expression, node.child
7787
)
88+
elif isinstance(node, nodes.ExplodeNode):
89+
for col_id in node.column_ids:
90+
curr_result = curr_result | _encode_type_refs_from_expr(col_id, node.child)
91+
elif isinstance(node, IGNORED_NODES):
92+
# Do nothing
93+
pass
94+
else:
95+
# For unseen nodes, do not raise errors as this is the logging path, but
96+
# we should cover those nodes either in the branches above, or place them
97+
# in the IGNORED_NODES collection.
98+
pass
7899

79100
return child_result | curr_result
80101

tests/system/small/core/logging/test_data_types.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@
1414

1515
from typing import Sequence
1616

17+
import pandas as pd
18+
import pyarrow as pa
19+
1720
from bigframes import dtypes
1821
from bigframes.core.logging import data_types
22+
import bigframes.pandas as bpd
1923

2024

2125
def encode_types(inputs: Sequence[dtypes.Dtype]) -> str:
@@ -99,3 +103,11 @@ def test_get_type_refs_window(scalars_df_index):
99103
expected_types = [dtypes.STRING_DTYPE, dtypes.BOOL_DTYPE, dtypes.INT_DTYPE]
100104

101105
assert data_types.encode_type_refs(node) == encode_types(expected_types)
106+
107+
108+
def test_get_type_refs_explode():
109+
df = bpd.DataFrame({"A": ["a", "b"], "B": [[1, 2], [3, 4, 5]]})
110+
node = df.explode("B")._block._expr.node
111+
expected_types = [pd.ArrowDtype(pa.list_(pa.int64()))]
112+
113+
assert data_types.encode_type_refs(node) == encode_types(expected_types)

0 commit comments

Comments
 (0)