pola-rs/polars · error · NotImplementedError

`sink_csv` is not supported by

Error message

`sink_csv` is not supported by {type(self).__name__}

What it means

Interface guard on the lazy engine wrapper classes: a particular engine (e.g. the in-memory/streaming engine) does not implement the sink_csv plan node, so calling LazyFrame.sink_csv routed through it raises naming the engine class that lacks support.

Solutions

  1. Use `engine='streaming'` which supports `sink_csv`.
  2. Use `lf.collect().write_csv(path)` as a non-sinking alternative.
  3. Implement `sink_csv` in your custom Engine subclass.
  4. Confirm sink support in the engine's documentation.

Example fix

// before
lf.sink_csv("out.csv", engine="custom")
// after
lf.sink_csv("out.csv", engine="streaming")
Defensive patterns

Strategy: try-catch

Validate before calling

if type(engine_obj).sink_csv is Engine.sink_csv:
    engine = "streaming"

Type guard

def supports_csv_sink(engine: object) -> bool:
    return type(engine).sink_csv is not Engine.sink_csv

Try / catch

try:
    lf.sink_csv(path, engine=eng)
except NotImplementedError:
    lf.collect().write_csv(path)

Prevention

When it happens

Trigger: Calling `LazyFrame.sink_csv(..., engine=<engine>)` where the engine class does not override `sink_csv` (e.g. custom engine).

Common situations: CSV export pipelines with a custom or non-streaming engine; code shared across engine configurations.

Related errors


AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18). Data as JSON: /api/errors/a6d072fd6412fcea. Report an issue: GitHub.

Appendix: source

Thrown at py-polars/src/polars/lazyframe/engine.py:260

        batch_size: int,
        datetime_format: str | None,
        date_format: str | None,
        time_format: str | None,
        float_scientific: bool | None,
        float_precision: int | None,
        decimal_comma: bool,
        null_value: str | None,
        quote_style: CsvQuoteStyle | None,
        maintain_order: bool,
        storage_options: StorageOptionsDict | None,
        credential_provider: CredentialProviderFunction | Literal["auto"] | None,
        sync_on_close: SyncOnCloseMethod | None,
        mkdir: bool,
        optimizations: QueryOptFlags,
    ) -> None:
        """See :meth:`polars.LazyFrame.sink_csv`."""
        msg = f"`sink_csv` is not supported by {type(self).__name__}"
        raise NotImplementedError(msg)

    def sink_ndjson(
        self,
        lf: LazyFrame,
        path: str | Path | IO[bytes] | IO[str] | PartitionBy,
        *,
        compression: Literal["uncompressed", "gzip", "zstd"],
        compression_level: int | None,
        check_extension: bool,
        maintain_order: bool,
        storage_options: StorageOptionsDict | None,
        credential_provider: CredentialProviderFunction | Literal["auto"] | None,
        sync_on_close: SyncOnCloseMethod | None,
        mkdir: bool,
        optimizations: QueryOptFlags,
    ) -> None:
        """See :meth:`polars.LazyFrame.sink_ndjson`."""
        msg = f"`sink_ndjson` is not supported by {type(self).__name__}"

View on GitHub (pinned to fe841f959e)