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

from_dicts() entered unreachable code when Categorical column's first value is null, then non-null later #7188

Closed
2 tasks done
carsonyl opened this issue Feb 25, 2023 · 1 comment · Fixed by #9145
Closed
2 tasks done
Labels
bug Something isn't working python Related to Python Polars

Comments

@carsonyl
Copy link

Polars version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of Polars.

Issue description

When using from_dicts() and specifying a Categorical column via schema=, it's possible to encounter pyo3_runtime.PanicException: internal error: entered unreachable code. This happens if the Categorical column's first value is null, and a subsequent row from the list of dicts has a non-null value for it.

This error doesn't happen when the Categorical column starts with a non-null value, or when the column type is instead Utf8.

Reproducible example

import polars as pl
pl.from_dicts(
    [
        {"A": None},
        {"A": "foo"},
    ],
    schema={
        "A": pl.Categorical
    },
)
# pyo3_runtime.PanicException: internal error: entered unreachable code

Expected behavior

The output of the example above should be equal to DataFrame([Series("A", [None, "foo"], dtype=Categorical)]).

Installed versions

---Version info---
Polars: 0.16.8
Index type: UInt32
Platform: Windows-10-10.0.22621-SP0
Python: 3.11.2 (tags/v3.11.2:878ead1, Feb  7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)]
---Optional dependencies---
pyarrow: 11.0.0
pandas: 1.5.3
numpy: 1.24.2
fsspec: <not installed>
connectorx: <not installed>
xlsx2csv: <not installed>
deltalake: <not installed>
matplotlib: <not installed>
@carsonyl carsonyl added bug Something isn't working python Related to Python Polars labels Feb 25, 2023
@jonashaag
Copy link
Contributor

This bug is still present in today's main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working python Related to Python Polars
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants