You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of Polars.
Reproducible example
import polars as pl
import datetime as dt
pl.LazyFrame({'x': [dt.datetime(2024, 1, 1, 1, 1)]}).sink_parquet('test.parquet')
(
pl.scan_parquet('test.parquet')
.filter(pl.col('x').dt.year())
.collect()
)
Log output
RUN STREAMING PIPELINE
[df -> parquet_sink]
thread 'polars-0' panicked at crates/polars-io/src/predicates.rs:30:29:
filter predicates was not of type boolean: SchemaMismatch(ErrString("invalid series dtype: expected `Boolean`, got `i32`"))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
File "/home/azureuser/test/test.py", line 9, in<module>.collect()
File "/home/azureuser/test/venv/lib/python3.10/site-packages/polars/lazyframe/frame.py", line 1942, in collect
return wrap_df(ldf.collect(callback))
pyo3_runtime.PanicException: filter predicates was not of type boolean: SchemaMismatch(ErrString("invalid series dtype: expected `Boolean`, got `i32`"))
Issue description
I wanted to filter a datetime column by year. But I forgot to include the == 2023 part of the filter condition. This means my query is invalid.
Expected behavior
My understanding is that a Panic is not the expected behavior no matter how invalid the user's input is.
I expect a more graceful warning like:
Filter condition must be a boolean
If I've misunderstood this, and panic is considered a reasonable response to such a bad query, then just close this issue.
This PR fixespola-rs#17391 by properly adding a `TypeCheckRule` to the
`ConversionOptimizer` that will verify that `filters` have a `Boolean`
datatype.
This already caught pola-rs#20424.
In the future, this can be expanded to type check additional parts of the IR
such as arithmetic operators.
Checks
Reproducible example
Log output
Issue description
I wanted to filter a datetime column by year. But I forgot to include the
== 2023
part of the filter condition. This means my query is invalid.Expected behavior
My understanding is that a Panic is not the expected behavior no matter how invalid the user's input is.
I expect a more graceful warning like:
If I've misunderstood this, and panic is considered a reasonable response to such a bad query, then just close this issue.
Installed versions
The text was updated successfully, but these errors were encountered: