pola-rs/polars · error · NotImplementedError
`sink_ndjson` is not supported by
Error message
`sink_ndjson` is not supported by {type(self).__name__} What it means
`sink_ndjson` streams a LazyFrame to newline-delimited JSON and is only implemented by sink-capable engines. The base `Engine` class raises NotImplementedError with this message for engines without the method.
Solutions
- Use `engine='streaming'`.
- Fallback: `lf.collect().write_ndjson(path)`.
- Implement `sink_ndjson` in your custom Engine.
- Verify engine sink capabilities before use.
Example fix
// before
lf.sink_ndjson("out.ndjson", engine="custom")
// after
lf.sink_ndjson("out.ndjson", engine="streaming") Defensive patterns
Strategy: try-catch
Validate before calling
if type(engine_obj).sink_ndjson is Engine.sink_ndjson:
engine = "streaming" Type guard
def supports_ndjson_sink(engine: object) -> bool:
return type(engine).sink_ndjson is not Engine.sink_ndjson Try / catch
try:
lf.sink_ndjson(path, engine=eng)
except NotImplementedError:
lf.collect().write_ndjson(path) Prevention
- Use engine='streaming' for NDJSON sinks
- Implement sink methods when subclassing Engine
- Keep non-sinking export fallbacks
When it happens
Trigger: Calling `LazyFrame.sink_ndjson(..., engine=<engine>)` with an engine lacking the `sink_ndjson` override.
Common situations: NDJSON export jobs with a custom engine; streaming examples run with a different engine selection.
Related errors
- `sink_csv` is not supported by
- `sink_ipc` is not supported by
- `sink_parquet` is not supported by
- `collect_all_async` is not supported by
- `collect_all` is not supported by
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/ba99001bf756a46e.
Report an issue: GitHub.
Appendix: source
Thrown at py-polars/src/polars/lazyframe/engine.py:279
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__}"
raise NotImplementedError(msg)
def sink_batches(
self,
lf: LazyFrame,
function: Callable[[DataFrame], bool | None],
*,
chunk_size: int | None,
maintain_order: bool,
optimizations: QueryOptFlags,
) -> None:
"""See :meth:`polars.LazyFrame.sink_batches`."""
msg = f"`sink_batches` is not supported by {type(self).__name__}"
raise NotImplementedError(msg)
class _LocalEngine(Engine):
"""Base for in-process engines backed by `PyLazyFrame`."""
View on GitHub (pinned to fe841f959e)