Skip to main content

read_csv_at_polars

Function read_csv_at_polars 

Source
pub fn read_csv_at_polars(path: &Path) -> Result<Value, String>
Expand description

Read a CSV through Polars’ parallel reader and hand back the usual Value::ArrowTable. This is what arrow.read_csv dispatches to when the df feature is on (the default for the lex toolchain): the arrow-rs CSV reader is single-threaded and was measured at ~10x the wall time of Polars’ on a 1M-row file — it dominated every read-then-query pipeline (see lex-frame’s bench/REPORT.md).

Contract is unchanged from the arrow-rs path: header row required, schema inferred from the first 100 rows, output columns normalised to the std.arrow v1 dtype surface (Int64 / Float64 / Utf8). Polars may infer types outside that surface (Boolean today; narrower ints defensively) — those are cast: ints widen to Int64, Float32 widens to Float64, everything else (Boolean, temporal) renders to Utf8. The old reader produced unusable columns for those inputs (present in the table, rejected by every kernel), so the cast is a strict upgrade, not a break.