Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic when filtering by non-boolean #17391

Open
2 tasks done
mdavis-xyz opened this issue Jul 3, 2024 · 0 comments
Open
2 tasks done

Panic when filtering by non-boolean #17391

mdavis-xyz opened this issue Jul 3, 2024 · 0 comments
Labels
A-panic Area: code that results in panic exceptions bug Something isn't working P-low Priority: low python Related to Python Polars

Comments

@mdavis-xyz
Copy link
Contributor

mdavis-xyz commented Jul 3, 2024

Checks

  • 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.

Installed versions

--------Version info---------
Polars:               1.0.0
Index type:           UInt32
Platform:             Linux-6.5.0-1022-azure-x86_64-with-glibc2.35
Python:               3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]

----Optional dependencies----
adbc_driver_manager:  <not installed>
cloudpickle:          <not installed>
connectorx:           <not installed>
deltalake:            <not installed>
fastexcel:            <not installed>
fsspec:               <not installed>
gevent:               <not installed>
great_tables:         <not installed>
hvplot:               <not installed>
matplotlib:           <not installed>
nest_asyncio:         <not installed>
numpy:                <not installed>
openpyxl:             <not installed>
pandas:               <not installed>
pyarrow:              <not installed>
pydantic:             <not installed>
pyiceberg:            <not installed>
sqlalchemy:           <not installed>
torch:                <not installed>
xlsx2csv:             <not installed>
xlsxwriter:           <not installed>
@mdavis-xyz mdavis-xyz added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Jul 3, 2024
@stinodego stinodego added A-panic Area: code that results in panic exceptions P-low Priority: low and removed needs triage Awaiting prioritization by a maintainer labels Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-panic Area: code that results in panic exceptions bug Something isn't working P-low Priority: low python Related to Python Polars
Projects
Status: Ready
Development

No branches or pull requests

2 participants