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

Commit 7682f7d

Browse files
committed
fix: apply typed NULL to unpivot for empty columns
1 parent 00dbe35 commit 7682f7d

File tree

2 files changed

+1
-14
lines changed

2 files changed

+1
-14
lines changed

bigframes/core/blocks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3429,7 +3429,7 @@ def unpivot(
34293429
for input_ids in unpivot_columns:
34303430
col_expr: ex.Expression
34313431
if not input_ids:
3432-
col_expr = ex.const(None)
3432+
col_expr = ex.const(None, dtype=bigframes.dtypes.INT_DTYPE)
34333433
else:
34343434
# row explode offset used to choose the input column
34353435
# we use offset instead of label as labels are not necessarily unique

tests/system/small/test_multiindex.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,19 +1492,6 @@ def test_multiindex_eq_const(scalars_df_index, scalars_pandas_df_index):
14921492
)
14931493

14941494

1495-
def test_count_empty_multiindex_columns(session):
1496-
df = pandas.DataFrame(
1497-
[], index=[1, 2], columns=pandas.MultiIndex.from_tuples([], names=["a", "b"])
1498-
)
1499-
bdf = session.read_pandas(df)
1500-
1501-
# count() operation unpivots columns, triggering the empty MultiIndex bug internally
1502-
count_df = bdf.count().to_pandas()
1503-
assert count_df.shape == (0,)
1504-
assert count_df.index.nlevels == 2
1505-
assert list(count_df.index.names) == ["a", "b"]
1506-
1507-
15081495
def test_dataframe_melt_multiindex(session):
15091496
# Tests that `melt` operations via count do not cause MultiIndex drops in Arrow
15101497
df = pandas.DataFrame({"A": [1], "B": ["string"], "C": [3]})

0 commit comments

Comments
 (0)