pola-rs / polars

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

panic when executing sql expression with IN operator in debug mode #18653

Open ZemanOndrej opened 1 week ago

ZemanOndrej commented 1 week ago

I am trying to execute sql expression like 'value' IN ('value2', 'value') and this debug_assertions panics https://github.com/pola-rs/polars/blob/5ccb238d62e2e3e471718462714a1c61d97c72c3/crates/polars-expr/src/expressions/apply.rs#L41-L46 In release mode the expression is executed successfully. why is this assertion needed?

alexander-beedie commented 1 week ago

Can you provide a reproducible test case? Thanks. (Not exactly sure how/where you're calling your SQL expression 🤔)

ZemanOndrej commented 1 week ago
use polars::{
    frame::DataFrame,
    prelude::{IntoLazy, NamedFrom},
    series::Series,
    sql::SQLContext,
};

fn main() {
    let series_data = Series::new("column1", ["a", "b", "c"]);
    let df = DataFrame::new(vec![series_data]).unwrap();
    let mut sql_context = SQLContext::new();
    sql_context.register("table1", df.lazy());
    let df = sql_context
        .execute("SELECT * FROM table1 WHERE 'a' IN ('b', 'a')")
        .unwrap();
    println!("{:?}", df.collect());
}

thread 'main' panicked at /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/polars-expr-0.42.0/src/expressions/apply.rs:45:13: expr String(a).is_in([Series]) is not implemented correctly. 'returns_scalar' and 'elementwise' are mutually exclusive stack backtrace: I know this kind of select statement is wrong but I would expect it to work. In release mode it works.