pola-rs/polars · error · TypeError
expected file to be a `str` since partition-by is set
Error message
expected file to be a `str` since partition-by is set
What it means
Error "expected file to be a `str` since partition-by is set" thrown in pola-rs/polars.
Source
Thrown at py-polars/src/polars/dataframe/frame.py:4362
table=tbl,
root_path=file,
**(pyarrow_options or {}),
)
else:
pa.parquet.write_table(
table=tbl,
where=file,
**(pyarrow_options or {}),
)
return
target: str | Path | IO[bytes] | PartitionBy = file
engine: EngineType = "streaming"
if partition_by is not None:
if not isinstance(file, str):
msg = "expected file to be a `str` since partition-by is set"
raise TypeError(msg)
from polars.io.partition import PartitionBy
target = PartitionBy(
file,
key=partition_by,
approximate_bytes_per_file=partition_chunk_size_bytes,
)
from polars.lazyframe.opt_flags import QueryOptFlags
self.lazy().sink_parquet(
target,
compression=compression,
compression_level=compression_level,
statistics=statistics,
row_group_size=row_group_size,
data_page_size=data_page_size,View on GitHub (pinned to df599052da)
When it happens
Trigger: Thrown at py-polars/src/polars/dataframe/frame.py:4362 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of pola-rs/polars@df599052da (2026-08-16).
Data as JSON: /api/errors/ae69d0756d36f4d7.
Report an issue: GitHub.