From 5cc9a974dd09ef2ca319a9c48f60f690e45963ea Mon Sep 17 00:00:00 2001 From: Orson Peters Date: Wed, 18 Sep 2024 15:11:28 +0200 Subject: [PATCH] refactor(rust): Fix zero-length len --- crates/polars-expr/src/reduce/convert.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/polars-expr/src/reduce/convert.rs b/crates/polars-expr/src/reduce/convert.rs index 279d77d6eb67..af3f72733efd 100644 --- a/crates/polars-expr/src/reduce/convert.rs +++ b/crates/polars-expr/src/reduce/convert.rs @@ -73,13 +73,14 @@ pub fn into_reduction( _ => unreachable!(), }, AExpr::Len => { - // Compute length on the first column, or if none exist we'll never - // be called and correctly return 0 as length anyway. + // Compute length on the first column, or if none exist we'll use + // a zero-length dummy series. let out: Box = Box::new(LenReduce::new()); let expr = if let Some(first_column) = schema.iter_names().next() { expr_arena.add(AExpr::Column(first_column.as_str().into())) } else { - expr_arena.add(AExpr::Literal(LiteralValue::Null)) + let dummy = Series::new_null(PlSmallStr::from_static("dummy"), 0); + expr_arena.add(AExpr::Literal(LiteralValue::Series(SpecialEq::new(dummy)))) }; (out, expr) },