Skip to content

pivot panic regression with fill_null as an aggregate_function= #26843

@cmdlineluser

Description

@cmdlineluser

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

df = pl.DataFrame({"x": [1, 2], "y": [3, 4], "z": [5, 6]})

df.pivot("x", index="y", aggregate_function=pl.element().first().fill_null(0))
# PanicException: implementation error, cannot get ref Int64 from Int32

Log output

...

Issue description

Last worked on 1.35.2:

shape: (2, 3)
┌─────┬─────┬─────┐
│ y   ┆ 1   ┆ 2   │
│ --- ┆ --- ┆ --- │
│ i64 ┆ i64 ┆ i64 │
╞═════╪═════╪═════╡
│ 3   ┆ 5   ┆ 0   │
│ 4   ┆ 0   ┆ 6   │
└─────┴─────┴─────┘

I posted a previous panic #25860 which may also be the same underlying issue.

Expected behavior

No panic.

Installed versions

Details
--------Version info---------
Polars:              1.38.1
Index type:          UInt32
Platform:            macOS-13.6.1-arm64-arm-64bit-Mach-O
Python:              3.14.2 (main, Dec  5 2025, 16:49:16) [Clang 15.0.0 (clang-1500.1.0.2.5)]
Runtime:             rt32

----Optional dependencies----
Azure CLI            <not installed>
adbc_driver_manager  1.10.0
altair               <not installed>
azure.identity       <not installed>
boto3                <not installed>
cloudpickle          3.1.2
connectorx           <not installed>
deltalake            1.4.1
fastexcel            <not installed>
fsspec               2026.2.0
gevent               <not installed>
google.auth          <not installed>
great_tables         <not installed>
matplotlib           3.10.8
numpy                2.4.1
openpyxl             <not installed>
pandas               3.0.1
polars_cloud         <not installed>
pyarrow              22.0.0
pydantic             2.12.5
pyiceberg            0.10.0
sqlalchemy           2.0.46
torch                <not installed>
xlsx2csv             <not installed>
xlsxwriter           3.2.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-panicArea: code that results in panic exceptionsbugSomething isn't workingneeds triageAwaiting prioritization by a maintainerpythonRelated to Python PolarsregressionIssue introduced by a new release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions