A minimal not-working example:
from pathlib import Path
import polars as pl
Alphas = pl.Enum(["hello"])
MiniStruct = pl.Struct({
"alpha": Alphas,
})
MiniStructs = pl.List(MiniStruct)
df = pl.DataFrame(
pl.Series("xs", [[] for _ in range(1)], dtype=MiniStructs)
)
path = Path("xs.arrow")
if path.exists():
path.unlink()
df.write_ipc(path)
Produces:
thread '<unnamed>' panicked at /home/runner/work/polars/polars/crates/polars-arrow/src/array/list/mod.rs:82:61:
called `Result::unwrap()` on an `Err` value: ComputeError(ErrString("ListArray's child's DataType must match. However, the expected DataType is Struct([Field { name: "alpha", data_type: Dictionary(UInt32, LargeUtf8, false), is_nullable: true, metadata: {"POLARS.CATEGORICAL_TYPE": "ENUM"} }]) while it got Struct([Field { name: "alpha", data_type: Dictionary(UInt32, LargeUtf8, false), is_nullable: true, metadata: {} }])."))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
PanicException Traceback (most recent call last)
/tmp/ipykernel_264688/3257874384.py in ?()
13 path = Path("xs.arrow")
14 if path.exists():
15 path.unlink()
16
---> 17 df.write_ipc(path)
~/bumblebee/.venv/lib/python3.12/site-packages/polars/dataframe/frame.py in ?(self, file, compression, future)
3251 issue_unstable_warning(
3252 "The `future` parameter of `DataFrame.write_ipc` is considered unstable."
3253 )
3254
-> 3255 self._df.write_ipc(file, compression, future)
3256 return file if return_bytes else None # type: ignore[return-value]
PanicException: called `Result::unwrap()` on an `Err` value: ComputeError(ErrString("ListArray's child's DataType must match. However, the expected DataType is Struct([Field { name: "alpha", data_type: Dictionary(UInt32, LargeUtf8, false), is_nullable: true, metadata: {"POLARS.CATEGORICAL_TYPE": "ENUM"} }]) while it got Struct([Field { name: "alpha", data_type: Dictionary(UInt32, LargeUtf8, false), is_nullable: true, metadata: {} }])."))