Skip to content

Commit

Permalink
fix: Fix empty scalar agg type (#20051)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 authored Nov 28, 2024
1 parent 9f3f012 commit 74d059f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/polars-core/src/frame/column/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ impl Column {
Column::Partitioned(s) => series_agg(s.as_materialized_series(), groups).into_column(),
Column::Scalar(s) => {
if s.is_empty() {
return self.clone();
return series_agg(s.as_materialized_series(), groups).into_column();
}

// We utilize the aggregation on Series to see:
Expand Down
9 changes: 9 additions & 0 deletions py-polars/tests/unit/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,12 @@ def test_raise_subnodes_18787() -> None:
pl.first().struct.field("a", "b").filter(pl.col("foo") == 1)
)
)


def test_scalar_agg_schema_20044() -> None:
assert (
pl.DataFrame(None, schema={"a": pl.Int64, "b": pl.String, "c": pl.String})
.with_columns(d=pl.col("a").max())
.group_by("c")
.agg(pl.col("d").mean())
).schema == pl.Schema([("c", pl.String), ("d", pl.Float64)])

0 comments on commit 74d059f

Please sign in to comment.