{"record":{"id":"ae69d0756d36f4d7","repo":"pola-rs/polars","slug":"expected-file-to-be-a-str-since-partition-by-is","errorCode":null,"errorMessage":"expected file to be a `str` since partition-by is set","messagePattern":"expected file to be a `str` since partition-by is set","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/dataframe/frame.py","lineNumber":4362,"sourceCode":"                    table=tbl,\n                    root_path=file,\n                    **(pyarrow_options or {}),\n                )\n            else:\n                pa.parquet.write_table(\n                    table=tbl,\n                    where=file,\n                    **(pyarrow_options or {}),\n                )\n\n            return\n\n        target: str | Path | IO[bytes] | PartitionBy = file\n        engine: EngineType = \"streaming\"\n        if partition_by is not None:\n            if not isinstance(file, str):\n                msg = \"expected file to be a `str` since partition-by is set\"\n                raise TypeError(msg)\n\n            from polars.io.partition import PartitionBy\n\n            target = PartitionBy(\n                file,\n                key=partition_by,\n                approximate_bytes_per_file=partition_chunk_size_bytes,\n            )\n\n        from polars.lazyframe.opt_flags import QueryOptFlags\n\n        self.lazy().sink_parquet(\n            target,\n            compression=compression,\n            compression_level=compression_level,\n            statistics=statistics,\n            row_group_size=row_group_size,\n            data_page_size=data_page_size,","sourceCodeStart":4344,"sourceCodeEnd":4380,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/dataframe/frame.py#L4344-L4380","documentation":"Error \"expected file to be a `str` since partition-by is set\" thrown in pola-rs/polars.","triggerScenarios":"Thrown at py-polars/src/polars/dataframe/frame.py:4362 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}