Skip to content

Commit b64e724

Browse files
authored
SNOW-1869802: Fix local testing pivot returning None (#2824)
1 parent 7494363 commit b64e724

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#### Bug Fixes
2424

25+
- Fixed a bug in local testing mode that caused a column to contain None when it should contain 0
2526
- Fixed a bug in StructField.from_json that prevented TimestampTypes with tzinfo from being parsed correctly.
2627

2728
### Snowpark pandas API Updates

src/snowflake/snowpark/mock/_plan.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1881,9 +1881,9 @@ def flatten_object_cell_func(cell):
18811881
# This requires us to wrap the aggregation function with extract logic to handle this special case.
18821882
def agg_function(column):
18831883
return (
1884-
agg_functions[agg_function_name](column.dropna())
1885-
if column.any()
1886-
else sentinel
1884+
sentinel
1885+
if column.isnull().all()
1886+
else agg_functions[agg_function_name](column.dropna())
18871887
)
18881888

18891889
default = (

tests/integ/scala/test_dataframe_aggregate_suite.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ def test_pivot(session):
6565
)
6666

6767

68+
def test_pivot_snow_1869802_repro(session):
69+
df = session.create_dataframe(
70+
[[1, "A", 10], [1, "B", 0], [2, "A", 11], [2, "B", 12]]
71+
)
72+
Utils.check_answer(
73+
df.pivot(pivot_col="_2", values=["A", "B"]).function("min")("_3"),
74+
[Row(1, 10, 0), Row(2, 11, 12)],
75+
False,
76+
)
77+
78+
6879
@pytest.mark.parametrize(
6980
"func,expected",
7081
[

0 commit comments

Comments
 (0)