{"record":{"id":"ba99001bf756a46e","repo":"pola-rs/polars","slug":"sink-ndjson-is-not-supported-by-type-self-na","errorCode":null,"errorMessage":"`sink_ndjson` is not supported by {type(self).__name__}","messagePattern":"`sink_ndjson` is not supported by (.+?)","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/lazyframe/engine.py","lineNumber":327,"sourceCode":"        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:\n        \"\"\"See :meth:`polars.LazyFrame.sink_ndjson`.\"\"\"\n        msg = f\"`sink_ndjson` is not supported by {type(self).__name__}\"\n        raise NotImplementedError(msg)\n\n    def sink_batches(\n        self,\n        lf: LazyFrame,\n        function: Callable[[DataFrame], bool | None],\n        *,\n        chunk_size: int | None,\n        maintain_order: bool,\n        lazy: bool,\n        optimizations: QueryOptFlags,\n    ) -> LazyFrame | None:\n        \"\"\"See :meth:`polars.LazyFrame.sink_batches`.\"\"\"\n        msg = f\"`sink_batches` is not supported by {type(self).__name__}\"\n        raise NotImplementedError(msg)\n\n\nclass _LocalEngine(Engine):\n    \"\"\"Base for in-process engines backed by `PyLazyFrame`.\"\"\"","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/lazyframe/engine.py#L309-L345","documentation":"`Engine.sink_ndjson` (engine.py:327) is the optional `Engine` hook behind `LazyFrame.sink_ndjson`. Unlike the parquet/ipc/csv sinks, `RemoteEngine` does NOT override it — only the local `_LocalEngine` family does. So this error fires both for custom engines and, concretely, for the built-in remote engine: NDJSON output to Polars Cloud is unimplemented.","triggerScenarios":"`lf.sink_ndjson('s3://bucket/out.ndjson', engine=pl.RemoteEngine())` raises '`sink_ndjson` is not supported by RemoteEngine'; likewise `lf.sink_ndjson(path, engine=my_engine)` for any custom `Engine` subclass lacking the override.","commonSituations":"Porting a local NDJSON export pipeline to Polars Cloud assuming format parity with sink_parquet; JSON-lines output required by downstream consumers (event streams, log pipelines) in a distributed setup; custom backends that never implemented NDJSON.","solutions":["Run the sink locally: `lf.sink_ndjson(path, engine='streaming')`","For remote execution, sink to a format RemoteEngine supports (parquet, ipc, csv) and convert afterwards","Collect remotely then write locally: `lf.collect(engine=remote).write_ndjson(path)`","Implement `sink_ndjson` on your custom `Engine` subclass"],"exampleFix":"# before\nlf.sink_ndjson('s3://bucket/out.ndjson', engine=pl.RemoteEngine())  # NotImplementedError\n\n# after\nlf.sink_parquet('s3://bucket/out.parquet', engine=pl.RemoteEngine())\n# or locally:\nlf.sink_ndjson('out.ndjson', engine='streaming')","handlingStrategy":"validation","validationCode":"from polars.lazyframe.engine import Engine\n\ndef engine_can_sink_ndjson(engine: pl.Engine) -> bool:\n    return type(engine).sink_ndjson is not Engine.sink_ndjson\n\nremote = pl.RemoteEngine()\nassert engine_can_sink_ndjson(remote) is False  # RemoteEngine lacks ndjson sinks\nassert engine_can_sink_ndjson(pl.StreamingEngine()) is True","typeGuard":null,"tryCatchPattern":"try:\n    lf.sink_ndjson(uri, engine=engine)\nexcept NotImplementedError as e:\n    if 'sink_ndjson' in str(e):\n        lf.sink_ndjson(uri, engine='streaming')  # local fallback\n    else:\n        raise","preventionTips":["Assume RemoteEngine supports only parquet/ipc/csv sinks","Keep NDJSON exports on local engines by policy","Surface per-engine format support in your app's engine-selection UI/docs"],"tags":["polars","engine","sink","ndjson","remote","not-implemented"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}