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: Raise informative error instead of panicking for list arithmetic on some invalid dtypes #19841

Merged
merged 3 commits into from
Nov 19, 2024

Conversation

nameexhaustion
Copy link
Collaborator

@nameexhaustion nameexhaustion commented Nov 18, 2024

Fixes #19839

We didn't validate that the list side of an arithmetic operation between list<->primitive columns has a list type at all nesting levels. This causes a panic when we later attempt to downcast to a numeric array type.

# Before
pyo3_runtime.PanicException: not implemented for dtype Struct([Field { name: "a", dtype: Int64 }])
# After
polars.exceptions.InvalidOperationError: cannot add columns: dtype was not list on all nesting levels: (left: list[struct[1]], right: i64)

Some drive-bys:

  • Rename arithmetic/list_borrowed.rs -> arithmetic/list.rs (under polars-core)
  • Rename arithmetic/test_list_arithmetic.py -> arithmetic/test_list.py (under py-polars/tests)

@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Nov 18, 2024
Copy link

codecov bot commented Nov 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.37%. Comparing base (402c15e) to head (2292054).
Report is 9 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #19841   +/-   ##
=======================================
  Coverage   79.37%   79.37%           
=======================================
  Files        1550     1550           
  Lines      214743   214763   +20     
  Branches     2460     2460           
=======================================
+ Hits       170457   170475   +18     
- Misses      43727    43729    +2     
  Partials      559      559           

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


🚨 Try these New Features:

@ritchie46 ritchie46 merged commit 6c34d59 into pola-rs:main Nov 19, 2024
25 checks passed
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.

Panic adding List(Struct) to Int64
2 participants