polars icon indicating copy to clipboard operation
polars copied to clipboard

`InvalidOperationError` when using fill_null after `.list.sum()` on bool list

Open 0xbe7a opened this issue 9 months ago • 0 comments

Checks

  • [X] I have checked that this issue has not already been reported.
  • [X] I have confirmed this bug exists on the latest version of Polars.

Reproducible example

import polars as pl

df = pl.DataFrame({"x": [[True, True, False]]})


df.select(
    pl.col("x")
    .list.sum()
    .fill_null(0)
)

Log output

Traceback (most recent call last):
  File "/Users/belastoyan/Documents/[redacted]/test.py", line 8, in <module>
    df.select(
  File "/Users/belastoyan/Documents/[redacted]]/.pixi/envs/default/lib/python3.12/site-packages/polars/dataframe/frame.py", line 8137, in select
    return self.lazy().select(*exprs, **named_exprs).collect(_eager=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/belastoyan/Documents/[redacted]/.pixi/envs/default/lib/python3.12/site-packages/polars/lazyframe/frame.py", line 1816, in collect
    return wrap_df(ldf.collect(callback))
                   ^^^^^^^^^^^^^^^^^^^^^
polars.exceptions.InvalidOperationError: could not determine supertype of: [bool, dyn int]

Issue description

This used to work on polars 0.20.25, now it's throwing an error. I believe it's a valid expression.

Expected behavior

Should output 2

Installed versions

--------Version info--------- Polars: 0.20.26 Index type: UInt32 Platform: macOS-14.4-arm64-arm-64bit Python: 3.12.3 | packaged by conda-forge | (main, Apr 15 2024, 18:35:20) [Clang 16.0.6 ]

----Optional dependencies---- adbc_driver_manager: cloudpickle: connectorx: deltalake: fastexcel: fsspec: gevent: hvplot: matplotlib: nest_asyncio: 1.6.0 numpy: 1.26.4 openpyxl: pandas: 2.2.2 pyarrow: 16.0.0 pydantic: pyiceberg: pyxlsb: sqlalchemy: torch: xlsx2csv: xlsxwriter:

0xbe7a avatar May 15 '24 21:05 0xbe7a