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

Problematic predicate pusdown when filtering based on list index. #17492

Closed
2 tasks done
Tachy0o-n opened this issue Jul 8, 2024 · 1 comment · Fixed by #17511
Closed
2 tasks done

Problematic predicate pusdown when filtering based on list index. #17492

Tachy0o-n opened this issue Jul 8, 2024 · 1 comment · Fixed by #17511
Assignees
Labels
A-optimizer Area: plan optimization accepted Ready for implementation bug Something isn't working P-medium Priority: medium python Related to Python Polars

Comments

@Tachy0o-n
Copy link

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

lf = pl.LazyFrame({'x' : [1,2,2], 'a' : [[1],[4,3], [5,4]]})

(lf.filter(pl.col('x')==2)
   .filter(pl.col('a').list.get(1).is_in([3]))
   .collect())

# polars.exceptions.ComputeError: get index is out of bounds

Log output

No response

Issue description

The error occurs because the second filter is applied first, when the list with length 1 is still present. Using .collect(predicate_pushdown=False) or .list.get(1, null_on_oob=True) (#16841) gives the expected result.

# shape: (1, 2)
# ┌─────┬───────────┐
# │ x   ┆ a         │
# │ --- ┆ ---       │
# │ i64 ┆ list[i64] │
# ╞═════╪═══════════╡
# │ 2   ┆ [4, 3]    │
# └─────┴───────────┘

Expected behavior

The output should not depend on optimizations.

Installed versions

--------Version info---------
Polars:               1.1.0
Index type:           UInt32
Platform:             Linux-5.15.0-113-generic-x86_64-with-glibc2.35
Python:               3.11.7 | packaged by conda-forge | (main, Dec 23 2023, 14:43:09) [GCC 12.3.0]

----Optional dependencies----
adbc_driver_manager:  0.10.0
cloudpickle:          <not installed>
connectorx:           0.3.2
deltalake:            <not installed>
fastexcel:            <not installed>
fsspec:               <not installed>
gevent:               <not installed>
great_tables:         <not installed>
hvplot:               <not installed>
matplotlib:           3.8.2
nest_asyncio:         1.6.0
numpy:                1.26.4
openpyxl:             <not installed>
pandas:               2.2.1
pyarrow:              15.0.1
pydantic:             <not installed>
pyiceberg:            <not installed>
sqlalchemy:           2.0.25
torch:                <not installed>
xlsx2csv:             <not installed>
xlsxwriter:           <not installed>
@Tachy0o-n Tachy0o-n added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Jul 8, 2024
@ritchie46
Copy link
Member

@nameexhaustion the code in the predicate pushdown checks is mostly yours. Can you add a case where we move a list.get (with raise oob) to local if we add a new filter?

@nameexhaustion nameexhaustion self-assigned this Jul 8, 2024
@nameexhaustion nameexhaustion added accepted Ready for implementation P-medium Priority: medium and removed needs triage Awaiting prioritization by a maintainer labels Jul 8, 2024
@github-project-automation github-project-automation bot moved this to Ready in Backlog Jul 8, 2024
@nameexhaustion nameexhaustion added the A-optimizer Area: plan optimization label Jul 8, 2024
@github-project-automation github-project-automation bot moved this from Ready to Done in Backlog Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-optimizer Area: plan optimization accepted Ready for implementation bug Something isn't working P-medium Priority: medium python Related to Python Polars
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants