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

.struct.field('*') PanicException when used after .list.to_struct() #17092

Open
2 tasks done
cmdlineluser opened this issue Jun 20, 2024 · 0 comments
Open
2 tasks done
Labels
A-panic Area: code that results in panic exceptions bug Something isn't working P-low Priority: low python Related to Python Polars

Comments

@cmdlineluser
Copy link
Contributor

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

import polars as pl

pl.select(pl.lit('a.b.c').str.split('.').list.to_struct().struct.field('*'))

Log output

thread '<unnamed>' panicked at crates/polars-plan/src/logical_plan/conversion/expr_expansion.rs:362:22:
index out of bounds: the len is 0 but the index is 0

Issue description

I'm not sure if this can actually work in a single context due to .list.to_struct() having an "unknown schema".

But the PanicException can be fixed.

Using a separate context works as expected.

>>> pl.select(pl.lit('a.b.c').str.split('.').list.to_struct()).select(pl.all().struct.field('*'))
shape: (1, 3)
┌─────────┬─────────┬─────────┐
│ field_0field_1field_2 │
│ ---------     │
│ strstrstr     │
╞═════════╪═════════╪═════════╡
│ abc       │
└─────────┴─────────┴─────────┘

Expected behavior

No panic exception.

Installed versions

--------Version info---------
Polars:               1.0.0-beta.1
Index type:           UInt32
Platform:             macOS-13.6.1-arm64-arm-64bit
Python:               3.12.2 (main, Feb  6 2024, 20:19:44) [Clang 15.0.0 (clang-1500.1.0.2.5)]

----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:                1.26.4
openpyxl:             <not installed>
pandas:               2.2.1
pyarrow:              15.0.2
pydantic:             <not installed>
pyiceberg:            <not installed>
sqlalchemy:           <not installed>
torch:                <not installed>
xlsx2csv:             <not installed>
xlsxwriter:           <not installed>
@cmdlineluser cmdlineluser added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Jun 20, 2024
@coastalwhite coastalwhite added P-low Priority: low A-panic Area: code that results in panic exceptions and removed needs triage Awaiting prioritization by a maintainer labels Jul 7, 2024
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 bug Something isn't working P-low Priority: low python Related to Python Polars
Projects
Status: Ready
Development

No branches or pull requests

2 participants