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

Strange type validation on when_then expressions #18767

Closed
2 tasks done
coastalwhite opened this issue Sep 16, 2024 · 0 comments
Closed
2 tasks done

Strange type validation on when_then expressions #18767

coastalwhite opened this issue Sep 16, 2024 · 0 comments
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars

Comments

@coastalwhite
Copy link
Collaborator

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

This succeeds:

df = pl.DataFrame({
    'a': [False, True],
    'b': [{ 'c': 1 }, None]
}).select(pl.when(pl.col.a).then(pl.struct({ 'b': 1 })).otherwise(pl.col.b))

This fails:

df = pl.DataFrame({
    'a': [False, True],
    'b': [{ 'c': 1 }, None]
}).select(pl.when(pl.col.a).then(pl.struct({ 'x': 1 })).otherwise(pl.col.b))

with a polars.exceptions.ColumnNotFoundError: x.

Log output

No response

Issue description

Strange error and inconsistent behavior.

Expected behavior

Consistent behavior

Installed versions

Replace this line with the output of pl.show_versions(). Leave the backticks in place.
@coastalwhite coastalwhite added bug Something isn't working python Related to Python Polars needs triage Awaiting prioritization by a maintainer labels Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars
Projects
None yet
Development

No branches or pull requests

1 participant