{"record":{"id":"a6d072fd6412fcea","repo":"pola-rs/polars","slug":"sink-csv-is-not-supported-by-type-self-name","errorCode":null,"errorMessage":"`sink_csv` is not supported by {type(self).__name__}","messagePattern":"`sink_csv` is not supported by (.+?)","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/lazyframe/engine.py","lineNumber":306,"sourceCode":"        date_format: str | None,\n        time_format: str | None,\n        float_scientific: bool | None,\n        float_precision: int | None,\n        decimal_comma: bool,\n        null_value: str | None,\n        quote_style: CsvQuoteStyle | None,\n        maintain_order: bool,\n        storage_options: StorageOptionsDict | None,\n        credential_provider: CredentialProviderFunction | Literal[\"auto\"] | None,\n        retries: int | None,\n        sync_on_close: SyncOnCloseMethod | None,\n        mkdir: bool,\n        lazy: bool,\n        optimizations: QueryOptFlags,\n    ) -> LazyFrame | None:\n        \"\"\"See :meth:`polars.LazyFrame.sink_csv`.\"\"\"\n        msg = f\"`sink_csv` is not supported by {type(self).__name__}\"\n        raise NotImplementedError(msg)\n\n    def sink_ndjson(\n        self,\n        lf: LazyFrame,\n        path: str | Path | IO[bytes] | IO[str] | PartitionBy,\n        *,\n        compression: Literal[\"uncompressed\", \"gzip\", \"zstd\"],\n        compression_level: int | None,\n        check_extension: bool,\n        maintain_order: bool,\n        storage_options: StorageOptionsDict | None,\n        credential_provider: CredentialProviderFunction | Literal[\"auto\"] | None,\n        retries: int | None,\n        sync_on_close: SyncOnCloseMethod | None,\n        mkdir: bool,\n        lazy: bool,\n        optimizations: QueryOptFlags,\n    ) -> LazyFrame | None:","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/lazyframe/engine.py#L288-L324","documentation":"`Engine.sink_csv` (engine.py:306) is the optional `Engine` hook behind `LazyFrame.sink_csv`. Its default stub raises `NotImplementedError` naming the engine. All built-in engines implement it (locally, or remotely via Polars Cloud with a restricted option set), so in practice only custom `Engine` subclasses missing the override trigger it.","triggerScenarios":"`lf.sink_csv(path, engine=my_engine)` where `my_engine` is a custom `pl.Engine` subclass without `sink_csv`. Note that with `RemoteEngine` this method exists but rejects unsupported options with a different ValueError (see error 456).","commonSituations":"Custom backend development where CSV export is deferred; mocking engines in tests of export pipelines; switching a sink-heavy workload to a plugin engine before all sink formats are implemented.","solutions":["Use a built-in engine: `lf.sink_csv(path, engine='streaming')` (default), or `engine=pl.RemoteEngine()` with only the supported options","Implement `sink_csv` on your `Engine` subclass with the stub's full keyword signature","Stopgap: `lf.collect().write_csv(path)`","Detect the missing capability before calling when engines are pluggable"],"exampleFix":"# before\nlf.sink_csv('out.csv', engine=my_custom_engine)  # NotImplementedError\n\n# after\nlf.sink_csv('out.csv', engine='streaming')\n# or implement `sink_csv` on MyEngine","handlingStrategy":"validation","validationCode":"from polars.lazyframe.engine import Engine\n\ndef engine_can_sink_csv(engine: pl.Engine) -> bool:\n    return type(engine).sink_csv is not Engine.sink_csv\n\nengine = my_engine if engine_can_sink_csv(my_engine) else pl.StreamingEngine()","typeGuard":null,"tryCatchPattern":"try:\n    lf.sink_csv(path, engine=my_engine)\nexcept NotImplementedError as e:\n    if 'sink_csv' in str(e):\n        lf.collect().write_csv(path)\n    else:\n        raise","preventionTips":["Treat sinks as optional engine capabilities, not guaranteed API","Centralize sink dispatch in one function with a documented fallback","Cover all sink formats in engine conformance tests"],"tags":["polars","engine","sink","csv","not-implemented","plugin"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}