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

list expressions that panic #18039

Closed
2 tasks done
evbo opened this issue Aug 4, 2024 · 2 comments · Fixed by #18611
Closed
2 tasks done

list expressions that panic #18039

evbo opened this issue Aug 4, 2024 · 2 comments · Fixed by #18611
Labels
A-panic Area: code that results in panic exceptions accepted Ready for implementation bug Something isn't working P-medium Priority: medium python Related to Python Polars

Comments

@evbo
Copy link

evbo commented Aug 4, 2024

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

without cast it panics:

df = pl.DataFrame({"a": [[3, 2, 1], [3,2,1], [3,2,1]], "b": [['0', '1', '2'], ['0','1'], ['1', '2']]})
df.select(pl.col("a").list.gather(
    pl.col("b"),
    # .cast(pl.List(pl.Int32))
    null_on_oob=True,
))

without pl.lit it panics:

df = pl.DataFrame({"a": [[3, 2, 1], [3,2,1], [3,2,1]], "b": [['0', '1', '2'], ['0','1'], ['1', '2']]})
df.select(pl.col("a").list.gather(
    pl.col("b").list.eval(pl.element() - 1), # should be pl.lit(1)
    # .cast(pl.List(pl.Int32))
    null_on_oob=True,
))

Log output

No response

Issue description

list expressions panic if types do not match expected

Expected behavior

a more descriptive error should be thrown explaining types are unexpected

Installed versions

--------Version info---------
Polars:               1.4.0
Index type:           UInt32
Platform:             Linux-5.15.0-117-generic-aarch64-with-glibc2.36
Python:               3.11.8 (main, Jun 11 2024, 13:54:05) [GCC 12.2.0]

----Optional dependencies----
adbc_driver_manager:  <not installed>
cloudpickle:          <not installed>
connectorx:           <not installed>
deltalake:            <not installed>
fastexcel:            <not installed>
fsspec:               <not installed>
gevent:               <not installed>
great_tables:         <not installed>
hvplot:               <not installed>
matplotlib:           <not installed>
nest_asyncio:         <not installed>
numpy:                <not installed>
openpyxl:             <not installed>
pandas:               <not installed>
pyarrow:              <not installed>
pydantic:             <not installed>
pyiceberg:            <not installed>
sqlalchemy:           <not installed>
torch:                <not installed>
xlsx2csv:             <not installed>
xlsxwriter:           <not installed>
@evbo evbo added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Aug 4, 2024
@coastalwhite coastalwhite added accepted Ready for implementation P-medium Priority: medium A-panic Area: code that results in panic exceptions and removed needs triage Awaiting prioritization by a maintainer labels Aug 4, 2024
@barak1412
Copy link
Contributor

@evbo @coastalwhite

I am not sure why it's a bug -
Column "b" is of type List[String], but gather expects list of integers.

The only problem I see is wrong message (due to lack of validation before).

What do you think?

@evbo
Copy link
Author

evbo commented Aug 31, 2024

@barak1412 yes wrong error reporting. I was recommended to file a bug since the panic is very vague about what is wrong especially to a newcomer. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-panic Area: code that results in panic exceptions 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