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

fix: Don't oob on nulls in list.get #17262

Merged
merged 1 commit into from
Jun 28, 2024
Merged

fix: Don't oob on nulls in list.get #17262

merged 1 commit into from
Jun 28, 2024

Conversation

ritchie46
Copy link
Member

fixes #17252

@ritchie46 ritchie46 changed the title fix: Don't oob on nulls fix: Don't oob on nulls in list.get Jun 28, 2024
@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Jun 28, 2024
Copy link

codecov bot commented Jun 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.88%. Comparing base (cdfeb4f) to head (45aaa44).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #17262   +/-   ##
=======================================
  Coverage   80.87%   80.88%           
=======================================
  Files        1470     1470           
  Lines      192631   192640    +9     
  Branches     2750     2750           
=======================================
+ Hits       155796   155814   +18     
+ Misses      36327    36318    -9     
  Partials      508      508           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ritchie46 ritchie46 merged commit 758d210 into main Jun 28, 2024
28 checks passed
@ritchie46 ritchie46 deleted the list branch June 28, 2024 12:05
@mcrumiller
Copy link
Contributor

mcrumiller commented Jun 28, 2024

@ritchie46 I think you missed the case where index is an column (https://github.com/pola-rs/polars/blob/main/crates/polars-plan/src/dsl/function_expr/list.rs#L426-L456):

s = pl.Series("a", [None, [1]], dtype=pl.List(pl.Int32))

# OK; fixed in PR
s.list.get(0, null_on_oob=False)

# not fixed in PR
df = pl.DataFrame({
    "a": s,
    "ind": [0, 0]
})
df.select(pl.col("a").list.get("ind", null_on_oob=False))
# polars.exceptions.ComputeError: get index is out of bounds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pl.Expr.list.get raises error on null values.
2 participants