pola-rs/polars · error
unimplemented
Error message
unimplemented
What it means
The streaming CSV reader does not implement negative pre-slices (taking the last N rows of the file before reading). When begin_read receives args whose pre_slice is a negative Slice, it hits an explicit unimplemented!() panic. Positive/offset pre-slices are supported; negative ones are not.
Solutions
- Disable the new streaming engine for this query (run with the in-memory/old engine or engine='in-memory') so negative slices are handled elsewhere.
- Restructure the query to avoid tail-only CSV reads, e.g. read fully then .tail(n).
- Upgrade Polars — this gap may be implemented in later versions.
- File an issue with the query if it should be supported.
Example fix
// before let df = LazyCsvSource::new(path).finish().tail(100).collect_with_engine streaming // after let df = lf.collect(engine = "in-memory")?.tail(100)
Defensive patterns
Strategy: fallback
Validate before calling
# If your plan relies on tail-style reads, avoid pushing negative slices to streaming CSV scans: q = lf # build without .tail(-n) style slice pushdown over streaming CSV
Type guard
def needs_full_read(slice: tuple | None) -> bool:
return slice is not None and slice[0] < 0 Try / catch
try:
df = lf.collect(engine="streaming")
except pl.exceptions.PolarsPanicError:
df = lf.collect(engine="in-memory") # negative slices handled here Prevention
- Use the in-memory engine for tail(-n) queries over CSV
- Read fully and .tail(n) in Python instead of relying on slice pushdown
- Check the streaming engine's supported slice kinds for your version
- Keep polars updated — unimplemented paths shrink over releases
When it happens
Trigger: Running a streaming query whose scan requires reading only the tail of a CSV (a negative slice reaching the CSV source's begin_read), e.g. certain lazy tail/last-N optimizations over scan_csv in the new streaming engine.
Common situations: Lazy plans where Polars pushes down a negative slice optimization into the CSV scan; users combining tail(-n) style queries with the streaming engine.
Related errors
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/39a18e4dfae568f6.
Report an issue: GitHub.
Appendix: source
Thrown at crates/polars-stream/src/nodes/io_sources/csv/mod.rs:190
missing_columns_policy,
num_pipelines,
disable_morsel_split: _,
last_morsel_pipelines: _,
callbacks:
FileReaderCallbacks {
file_schema_tx,
n_rows_in_file_tx,
row_position_on_end_tx,
},
} = args
else {
panic!("unsupported args: {:?}", args)
};
assert!(row_index.is_none()); // Handled outside the reader for now.
match &pre_slice {
Some(Slice::Negative { .. }) => unimplemented!(),
// We don't account for comments when slicing lines. We should never hit this panic -
// the FileReaderBuilder does not indicate PRE_SLICE support when we have a comment
// prefix.
Some(pre_slice)
if self.options.parse_options.comment_prefix.is_some() && pre_slice.len() > 0 =>
{
panic!("{pre_slice:?}")
},
_ => {},
}
// There are two byte sourcing strategies `ReaderSource`: (a) async parallel prefetch using a
// streaming pipeline, or (b) memory-mapped, only to be used for uncompressed local files.
// The `compressed_reader` (of type `ByteSourceReader`) abstracts these source types.
// The `use_async_prefetch` flag controls the optional pipeline startup behavior.
let use_async_prefetch =View on GitHub (pinned to fe841f959e)