From 49864864cbf2731a0d921fcf21e47bf48348b953 Mon Sep 17 00:00:00 2001 From: Ritchie Vink Date: Wed, 22 Feb 2023 10:29:17 +0100 Subject: [PATCH] fix(rust, python): allow fill_null in eager if type now known --- .../src/dsl/function_expr/fill_null.rs | 20 ++++++------- py-polars/tests/unit/test_functions.py | 28 +++++++++++++++++++ 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/polars/polars-lazy/polars-plan/src/dsl/function_expr/fill_null.rs b/polars/polars-lazy/polars-plan/src/dsl/function_expr/fill_null.rs index cb9c39991249..0ba60976ab59 100644 --- a/polars/polars-lazy/polars-plan/src/dsl/function_expr/fill_null.rs +++ b/polars/polars-lazy/polars-plan/src/dsl/function_expr/fill_null.rs @@ -4,20 +4,16 @@ pub(super) fn fill_null(s: &[Series], super_type: &DataType) -> PolarsResult None: assert df.select(pl.col("a").cast(pl.UInt64).diff()).to_dict(False) == { "a": [None, -10, 20] } + + +@typing.no_type_check +def test_fill_null_unknown_output_type() -> None: + df = pl.DataFrame( + { + "a": [ + None, + 2, + 3, + 4, + 5, + ] + } + ) + assert df.with_columns( + np.exp(pl.col("a")).fill_null(pl.lit(1, pl.Float64)) + ).to_dict(False) == { + "a": [ + 1.0, + 7.38905609893065, + 20.085536923187668, + 54.598150033144236, + 148.4131591025766, + ] + }