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

Broken in 1.10.0: Cannot extract struct values within list #19345

Closed
2 tasks done
aersam opened this issue Oct 21, 2024 · 5 comments · Fixed by #19438
Closed
2 tasks done

Broken in 1.10.0: Cannot extract struct values within list #19345

aersam opened this issue Oct 21, 2024 · 5 comments · Fixed by #19438
Assignees
Labels
accepted Ready for implementation bug Something isn't working P-high Priority: high python Related to Python Polars regression Issue introduced by a new release

Comments

@aersam
Copy link

aersam commented Oct 21, 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

print(
    pl.DataFrame(
        [
            {
                "a": [
                    {
                        "b": 1.0,
                        "c": 4,
                    }
                ]
            }
        ],
        {
            "a": pl.List(
                pl.Struct(
                    {
                        "b": pl.Float64(),
                        "c": pl.Float64(),
                    }
                )
            ),
        },
    ).select(
        pl.col("a").list.eval(
            pl.element().struct.field("b"),
        )
    )
)

Log output

Traceback (most recent call last):
  File "C:\Projects\BMS_Github\deltalake2db\repo.py", line 25, in <module>
    ).select(
      ^^^^^^^
  File "C:\Projects\BMS_Github\deltalake2db\.venv\Lib\site-packages\polars\dataframe\frame.py", line 9021, in select
    return self.lazy().select(*exprs, **named_exprs).collect(_eager=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Projects\BMS_Github\deltalake2db\.venv\Lib\site-packages\polars\lazyframe\frame.py", line 2055, in collect
    return wrap_df(ldf.collect(callback))
                   ^^^^^^^^^^^^^^^^^^^^^
polars.exceptions.ColumnNotFoundError

Issue description

This should work as it did up to 1.9.0

Expected behavior

Print the dataframe

Installed versions

--------Version info---------
Polars:              1.10.0
Index type:          UInt32
Platform:            Windows-10-10.0.19045-SP0
Python:              3.11.1 (tags/v3.11.1:a7a450f, Dec  6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)]
LTS CPU:             False

----Optional dependencies----
adbc_driver_manager  <not installed>
altair               <not installed>
cloudpickle          <not installed>
connectorx           <not installed>
deltalake            0.18.1
fastexcel            <not installed>
fsspec               2024.10.0
gevent               <not installed>
great_tables         <not installed>
matplotlib           <not installed>
nest_asyncio         <not installed>
numpy                2.1.2
openpyxl             <not installed>
pandas               2.2.3
pyarrow              17.0.0
pydantic             <not installed>
pyiceberg            <not installed>
sqlalchemy           <not installed>
torch                <not installed>
xlsx2csv             <not installed>
xlsxwriter           <not installed>
@aersam aersam added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels Oct 21, 2024
@cmdlineluser
Copy link
Contributor

It seems there is now some general breakage due to how pl.element() is currently implemented.

>>> print(pl.element())
col("")

#19317

@aersam
Copy link
Author

aersam commented Oct 21, 2024

If pl.element is completely broken, I really hope for a fast bug fix... This could break lots of stuff

@coastalwhite coastalwhite added accepted Ready for implementation P-medium Priority: medium and removed needs triage Awaiting prioritization by a maintainer labels Oct 22, 2024
@github-project-automation github-project-automation bot moved this to Ready in Backlog Oct 22, 2024
@ritchie46
Copy link
Member

Can we get a bisect here?

@cmdlineluser
Copy link
Contributor

cmdlineluser commented Oct 22, 2024

@ritchie46 It seemed to be #19195 to me.

(I posted some extra details in #19317)

pl.element() still works, it is not completely broken:

>>> pl.Series([[1, 2]]).list.eval(pl.element() + 1)
shape: (1,)
Series: '' [list[i64]]
[
	[2, 3]
]

It just seems that there a few different ways to hit the col("") lookup behaviour.

@adamreeve
Copy link
Contributor

We've also hit this regression and I can confirm it is caused by #19195, this works with the parent commit (1cc2cb8) but fails with 251e171.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Ready for implementation bug Something isn't working P-high Priority: high python Related to Python Polars regression Issue introduced by a new release
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

6 participants