Open
Description
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
from datetime import date
df = pl.DataFrame({'dt': [date(2025, 1, 1)] * 2})
df.with_columns(dt_list=pl.concat_list(pl.col('dt'), None))
Log output
File .../site-packages/polars/dataframe/frame.py:9806, in DataFrame.with_columns(self, *exprs, **named_exprs)
9660 def with_columns(
9661 self,
9662 *exprs: IntoExpr | Iterable[IntoExpr],
9663 **named_exprs: IntoExpr,
9664 ) -> DataFrame:
9665 """
9666 Add columns to this DataFrame.
9667
(...) 9804 └─────┴──────┴─────────────┘
9805 """
-> 9806 return self.lazy().with_columns(*exprs, **named_exprs).collect(_eager=True)
File .../site-packages/polars/_utils/deprecation.py:93, in deprecate_streaming_parameter.<locals>.decorate.<locals>.wrapper(*args, **kwargs)
89 kwargs["engine"] = "in-memory"
91 del kwargs["streaming"]
---> 93 return function(*args, **kwargs)
File .../site-packages/polars/lazyframe/frame.py:2188, in LazyFrame.collect(self, type_coercion, _type_check, predicate_pushdown, projection_pushdown, simplify_expression, slice_pushdown, comm_subplan_elim, comm_subexpr_elim, cluster_with_columns, collapse_joins, no_optimization, engine, background, _check_order, _eager, **_kwargs)
2186 # Only for testing purposes
2187 callback = _kwargs.get("post_opt_callback", callback)
-> 2188 return wrap_df(ldf.collect(engine, callback))
PanicException: called `Result::unwrap()` on an `Err` value: SchemaMismatch(ErrString("type Int32 is incompatible with expected type Date"))
Issue description
- The exception doesn't happen with just one row in the df
- The exception also only occurs if None is at the end of the list, and if there is only one date.
Expected behavior
Create a list column called "dt_list", containing one date and a null.
Installed versions
--------Version info---------
Polars: 1.26.0
Index type: UInt32
Platform: Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-with-glibc2.39
Python: 3.12.3 (main, Feb 4 2025, 14:48:35) [GCC 13.3.0]
LTS CPU: False
----Optional dependencies----
Azure CLI <not installed>
adbc_driver_manager <not installed>
altair <not installed>
azure.identity <not installed>
boto3 <not installed>
cloudpickle <not installed>
connectorx <not installed>
deltalake <not installed>
fastexcel <not installed>
fsspec 2025.2.0
gevent <not installed>
google.auth <not installed>
great_tables <not installed>
matplotlib <not installed>
numpy <not installed>
openpyxl <not installed>
pandas <not installed>
polars_cloud <not installed>
pyarrow 19.0.1
pydantic 2.10.6
pyiceberg <not installed>
sqlalchemy <not installed>
torch <not installed>
xlsx2csv <not installed>
xlsxwriter <not installed>