pola-rs / polars

Dataframes powered by a multithreaded, vectorized query engine, written in Rust
https://docs.pola.rs
Other
30.57k stars 1.98k forks source link

min/max operations on i16 list with None elements #17310

Closed kgv closed 5 months ago

kgv commented 5 months ago

Checks

Reproducible example

let df = df! {
    "List" => [Series::from_iter([None::<i16>, None, None])],
    // "List" => [Series::from_iter([None::<i32>, None, None])],
}?;
println!("df: {df}");
let df = df
    .lazy()
    .with_columns([
        col("List").list().min().name().suffix(".Min"), // if i16 - Err; if i32 - Ok: List.Min = null
        col("List").list().max().name().suffix(".Max"), // if i16 - Err; if i32 - Ok: List.Max = null
        col("List").list().sum().name().suffix(".Sum"), // Ok: List.Sum = 0
    ])
    .collect()?;
println!("df: {df}");

Log output

```shell thread 'polars-18' panicked at C:\Users\9\.cargo\git\checkouts\polars-b0d90607192fd414\59d2529\crates\polars-ops\src\chunked_array\list\min_max.rs:87:17: not implemented for dtype Int16 stack backtrace: 0: std::panicking::begin_panic_handler at /rustc/da159eb331b27df528185c616b394bb0e1d2a4bd/library\std\src\panicking.rs:652 1: core::panicking::panic_fmt at /rustc/da159eb331b27df528185c616b394bb0e1d2a4bd/library\core\src\panicking.rs:72 2: polars_ops::chunked_array::list::min_max::list_min_function::inner at C:\Users\9\.cargo\git\checkouts\polars-b0d90607192fd414\59d2529\crates\polars-ops\src\chunked_array\list\min_max.rs:87 3: polars_ops::chunked_array::list::namespace::has_inner_nulls at C:\Users\9\.cargo\git\checkouts\polars-b0d90607192fd414\59d2529\crates\polars-ops\src\chunked_array\list\namespace.rs:26 4: polars_ops::chunked_array::list::min_max::list_min_function at C:\Users\9\.cargo\git\checkouts\polars-b0d90607192fd414\59d2529\crates\polars-ops\src\chunked_array\list\min_max.rs:109 5: polars_plan::dsl::function_expr::list::min at C:\Users\9\.cargo\git\checkouts\polars-b0d90607192fd414\59d2529\crates\polars-plan\src\dsl\function_expr\list.rs:543 6: polars_plan::dsl::function_expr::list::impl$2::from::closure$5 at C:\Users\9\.cargo\git\checkouts\polars-b0d90607192fd414\59d2529\crates\polars-plan\src\dsl\function_expr\mod.rs:838 7: polars_plan::dsl::expr_dyn_fn::impl$0::call_udf at C:\Users\9\.cargo\git\checkouts\polars-b0d90607192fd414\59d2529\crates\polars-plan\src\dsl\expr_dyn_fn.rs:83 8: polars_expr::expressions::apply::ApplyExpr::eval_and_flatten at C:\Users\9\.cargo\git\checkouts\polars-b0d90607192fd414\59d2529\crates\polars-expr\src\expressions\apply.rs:127 9: polars_expr::expressions::apply::impl$1::evaluate at C:\Users\9\.cargo\git\checkouts\polars-b0d90607192fd414\59d2529\crates\polars-expr\src\expressions\apply.rs:335 10: polars_expr::expressions::alias::impl$1::evaluate at C:\Users\9\.cargo\git\checkouts\polars-b0d90607192fd414\59d2529\crates\polars-expr\src\expressions\alias.rs:32 11: polars_mem_engine::executors::projection_utils::run_exprs_par::closure$0::closure$0 at C:\Users\9\.cargo\git\checkouts\polars-b0d90607192fd414\59d2529\crates\polars-mem-engine\src\executors\projection_utils.rs:203 12: core::ops::function::impls::impl$1::call_mut at /rustc/da159eb331b27df528185c616b394bb0e1d2a4bd\library\core\src\ops\function.rs:272 13: core::ops::function::impls::impl$4::call_once at /rustc/da159eb331b27df528185c616b394bb0e1d2a4bd\library\core\src\ops\function.rs:305 14: enum2$,alloc::alloc::Global> > > >::map at /rustc/da159eb331b27df528185c616b394bb0e1d2a4bd\library\core\src\option.rs:1075 15: core::iter::adapters::map::impl$2::next at /rustc/da159eb331b27df528185c616b394bb0e1d2a4bd\library\core\src\iter\adapters\map.rs:108 16: core::iter::adapters::map::impl$2::next at /rustc/da159eb331b27df528185c616b394bb0e1d2a4bd\library\core\src\iter\adapters\map.rs:108 17: core::iter::adapters::take_while::impl$2::next at /rustc/da159eb331b27df528185c616b394bb0e1d2a4bd\library\core\src\iter\adapters\take_while.rs:47 18: core::iter::adapters::map::impl$2::next at /rustc/da159eb331b27df528185c616b394bb0e1d2a4bd\library\core\src\iter\adapters\map.rs:108 19: alloc::vec::Vec::extend_desugared at /rustc/da159eb331b27df528185c616b394bb0e1d2a4bd\library\alloc\src\vec\mod.rs:3064 20: alloc::vec::spec_extend::impl$0::spec_extend,alloc::alloc::Global> >,rayon::iter::map::MapConsumer,alloc::alloc::Global>,core::panic::unwind_safe::AssertUnwindSafe,alloc::alloc::Global> >,rayon::iter::map::MapConsumer< at C:\Users\9\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\join\mod.rs:142 34: rayon_core::registry::Registry::in_worker at C:\Users\9\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:496 35: rayon_core::registry::in_worker,alloc::alloc::Glob at C:\Users\9\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\registry.rs:953 36: rayon_core::join::join_context at C:\Users\9\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\join\mod.rs:132 37: rayon::iter::plumbing::bridge_producer_consumer::helper,alloc::alloc::Global> >,rayon::iter::map::MapConsumer,alloc::alloc::Global> >,pol at C:\Users\9\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-1.10.0\src\iter\extend.rs:588 47: rayon::iter::from_par_iter::collect_extended at C:\Users\9\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-1.10.0\src\iter\from_par_iter.rs:20 48: rayon::iter::from_par_iter::impl$0::from_par_iter at C:\Users\9\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-1.10.0\src\iter\from_par_iter.rs:33 49: rayon::iter::ParallelIterator::collect at C:\Users\9\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-1.10.0\src\iter\mod.rs:2069 50: rayon::result::impl$4::from_par_iter,polars_core::series::Series,enum2$,rayon::iter::map::Map,enum2$ > >,core::panic::unwind_safe::AssertUnwindSafe,enum2$ > > > >::call at C:\Users\9\.cargo\registry\src\index.crates.io-6f17d22bba15001f\rayon-core-1.12.1\src\job.rs:218 62: rayon_core::job::impl$4::execute,rayon_core::registry::impl$6::in_worker_cold::closure$0::closure_env$0

Issue description

min/max operations on i16 list with None elements throws Err: "not implemented for dtype Int16" but i32 is Ok.

Related: #13978

Expected behavior

min or max returns null

Installed versions

features = [ "dtype-array", "dtype-struct", "lazy", "pivot", "polars-ops", "regex", "row_hash", "serde", ]
kgv commented 5 months ago

add "dtype-i16" feature