ihb2032/MoonFrame/io does not have a README file

    CsvReadOptions

    pub struct CsvReadOptions {
    has_header : Bool
    delimiter : Char
    infer_schema_rows : Int
    strict_column_count : Bool
    on_parse_error : OnParseError
    allow_nonfinite_floats : Bool
    strict_quotes : Bool
    // private fields
    }

    Options that control how a CSV input is parsed into a DataFrame.

    • has_header — when true, the first row supplies column names. When false, every row is treated as data and column names are synthesised as "column1", "column2", … in declaration order; the first data row fixes the column count, so a later wider row's trailing cells are dropped under the lenient default (set strict_column_count = true to reject a ragged row instead).
    • delimiter — field separator passed through to NyaCSV.
    • infer_schema_rows — number of leading rows scanned when guessing each column's dtype. 0 (or any value <= 0) lifts the cap and scans every row, trading a slower inference pass for never mis-guessing a column from a prefix. Cells past a finite window are still parsed under the chosen dtype; one that doesn't fit is handled per on_parse_error.
    • null_values — raw strings that should be treated as null cells (both for type inference, which skips them, and for the final typed column, where they become None). The default [""] matches the empty string only, which is how an absent CSV cell is typically represented. A cell a ragged short row never held is null regardless of this list — the mapping decides what a read value means, and no value was read. Read it back through the null_values() accessor: the field itself is private, and both it and the constructor copy, so the token list a reader uses cannot be changed after the options are built.
    • strict_column_count — when true, every data row must have exactly as many cells as the header declares; a ragged row (too few or too many cells) raise ParseError instead of being silently null-padded (short row) or truncated (long row). Defaults to false, preserving the lenient behaviour that tolerates ragged rows (a permissive CSV idiom, and the reader's long-standing default).
    • on_parse_error — what to do when a non-null cell past the inference window fails to parse under its column's locked-in dtype. Raise (default) fails with ParseError(Cell(...)); Null downgrades the offending cell to a null cell and keeps the column's inferred dtype.
    • dtypes — per-column dtype overrides that pin a column's type instead of inferring it, as a name → DataType map. Only the seven dtypes a reader can parse — the four inference picks (Int / Float / Bool / String) plus the three rider dtypes a pin carries (Date / Timestamp / Decimal, read back through the writers' exact text forms) — can be pinned; anything else is refused with InvalidOperation at read time, as is a name the input does not carry (a pin is an assertion about the input; a misspelt one fails rather than silently does nothing). Columns not named keep their inferred dtype. A pinned column skips inference entirely, so it locks in even when its cells would have inferred differently — and a cell that does not parse under the pin is handled per on_parse_error, exactly as a post-window mismatch is. The map is copied, so mutating it afterwards cannot alter the options; read it back through the dtypes() accessor.
    • allow_nonfinite_floats — when true (default), the float probe accepts every non-finite result: the nan / inf / infinity literals, and a finite literal that overflows Double to a signed Infinity (1e999), so a column of those tokens infers as Float. When false, the probe rejects them, so such a column falls back to String instead of being silently retyped to Float (a non-finite token past the window is then a parse failure handled per on_parse_error).
    • strict_quotes — when true, the input is pre-scanned and an unterminated quoted field, text after a closing quote, or a bare quote inside an unquoted field raise ParseError instead of being repaired by the lenient tokeniser. Defaults to false.

    CsvReadOptions::CsvReadOptions

    fn CsvReadOptions::CsvReadOptions(has_header? : Bool, delimiter? : Char, infer_schema_rows? : Int, null_values? : Array[String], strict_column_count? : Bool, on_parse_error? : OnParseError, allow_nonfinite_floats? : Bool, strict_quotes? : Bool, dtypes? : Map[String,
    DataType
    ]) -> CsvReadOptions

    Build read options. Every field has a default: header on, comma delimiter, scan the first 100 rows for inference, treat the empty string as null, tolerate ragged rows, fail the read on a cell that doesn't fit its inferred dtype, accept non-finite float literals, and tokenise leniently. CsvReadOptions::CsvReadOptions() is the all-defaults reader; name only what differs, as in CsvReadOptions::CsvReadOptions(delimiter=';', strict_quotes=true).

    null_values and dtypes are copied, so mutating them afterwards cannot alter the options.

    CsvReadOptions::dtypes

    The per-column dtype overrides. A fresh Map is returned, so a caller cannot reach into the options and change what the reader pins — the same reason the constructor copies its input.

    CsvReadOptions::null_values

    fn CsvReadOptions::null_values(self : CsvReadOptions) -> Array[String]

    The raw strings treated as null cells. A fresh array is returned, so a caller cannot reach into the options and change what the reader nulls out — the same reason the constructor copies its input.

    CsvWriteOptions

    pub struct CsvWriteOptions {
    header : Bool
    delimiter : Char
    null_value : String
    sanitize_formulas : Bool
    line_terminator : String
    }

    Options that control how a DataFrame is rendered as CSV text.

    • header — when true, the first emitted row is the column names; when false, only data rows are written.
    • delimiter — field separator written between cells.
    • null_value — the literal string written in place of a null cell. The default empty string round-trips with the reader's default null_values.
    • sanitize_formulas — when true, a String cell beginning with =, +, -, @, a tab, or a carriage return is prefixed with a single quote so a spreadsheet reads it as text. Deliberately lossy: such a cell reads back with the leading quote. Defaults to false.
    • line_terminator — the string written after every row. The default "\n" (LF) matches every mainstream writer; RFC 4180's letter calls for "\r\n" (CRLF), and the reader accepts LF, CRLF, and CR alike, so either choice round-trips. Must not be empty — an empty terminator would fuse the rows into one.

    CsvWriteOptions::CsvWriteOptions

    fn CsvWriteOptions::CsvWriteOptions(header? : Bool, delimiter? : Char, null_value? : String, sanitize_formulas? : Bool, line_terminator? : String) -> CsvWriteOptions raise
    DataError

    Build write options. Every field has a default: header on, comma delimiter, null cells emitted as the empty string, no formula sanitisation, and LF line endings. CsvWriteOptions::CsvWriteOptions() is the all-defaults writer; name only what differs, as in CsvWriteOptions::CsvWriteOptions(delimiter=';'). The line_terminator must be composed of \n and \r alone (an empty one, or one holding any other character, raises InvalidOperation): the reader breaks lines on those two characters only, so any other terminator would write a file whose rows fuse or whose last cell glues the terminator on — every CR/LF combination ("\n", "\r\n", "\r", "\n\n", …) round-trips cleanly.

    JsonReadOptions

    pub struct JsonReadOptions {
    infer_schema_rows : Int
    on_parse_error : OnParseError
    reject_duplicate_keys : Bool
    allow_nonfinite_floats : Bool
    // private fields
    }

    Options that control how a JSON records payload is parsed into a DataFrame.

    • infer_schema_rows — number of leading records inspected when guessing each column's dtype. 0 (or any value <= 0) lifts the cap and scans every record. Records past a finite window are still parsed under the chosen dtype; one that doesn't fit is handled per on_parse_error.
    • on_parse_error — what to do when a non-null cell past the inference window fails to parse under its column's locked-in dtype: Raise (default) fails with ParseError(Cell(...)); Null downgrades the offending cell to a null and continues.
    • reject_duplicate_keys — whether an object repeating a key is an error. The default false keeps the common JSON reading: a repeated key survives only as its last value, the earlier ones silently dropped. true rejects the read instead — ParseError(Message(...)) naming the key and the line / column it repeated at — so a payload that would silently lose cells fails loudly. The check rides the parser itself (which reports whichever trouble it meets first: a repeat ahead of a syntax error surfaces as the repeat, and vice versa).
    • allow_nonfinite_floats — when true (default), a number whose magnitude overflows Double (e.g. 1e999) infers the column as Float holding ±Infinity. When false, such a number is not Float evidence — the column stays String, the CSV reader's allow_nonfinite_floats rule, so a silent retype to Float(∞) cannot happen either way a file is read.
    • dtypes — per-column dtype overrides that pin a column's type instead of inferring it, as a name → DataType map. Only the seven dtypes a reader can parse — the four inference picks (Int / Float / Bool / String) plus the three rider dtypes a pin carries (Date / Timestamp / Decimal, read back through the writers' exact text forms, so the cell must be a JSON String) — can be pinned; anything else is refused with InvalidOperation at read time, as is a name the input does not carry (a pin is an assertion about the input; a misspelt one fails rather than silently does nothing). Columns not named keep their inferred dtype. A pinned column skips inference entirely, and a cell that does not parse under the pin — a JSON String in a column pinned Int, say, since JSON has strong types and no "1" → 1 coercion — is handled per on_parse_error. The map is copied, so mutating it afterwards cannot alter the options; read it back through the dtypes() accessor.

    The NDJSON reader shares this type: the two formats differ in framing, not in what there is to configure.

    JsonReadOptions::JsonReadOptions

    fn JsonReadOptions::JsonReadOptions(infer_schema_rows? : Int, on_parse_error? : OnParseError, reject_duplicate_keys? : Bool, allow_nonfinite_floats? : Bool, dtypes? : Map[String,
    DataType
    ]) -> JsonReadOptions

    Build read options. Every field has a default: scan the first 100 records for inference, fail the read on a cell that doesn't fit its inferred dtype, let a repeated object key keep its last value (the common JSON reading), and accept overflow-to-Infinity numbers as Float cells. JsonReadOptions::JsonReadOptions() is the all-defaults reader; name only what differs, as in JsonReadOptions::JsonReadOptions(on_parse_error=Null). dtypes is copied, so mutating the map afterwards cannot alter the options.

    JsonReadOptions::dtypes

    The per-column dtype overrides. A fresh Map is returned, so a caller cannot reach into the options and change what the reader pins — the same reason the constructor copies its input.

    OnParseError

    pub(all) enum OnParseError {
    Raise
    Null
    } derive(Eq,
    Debug
    )

    What a reader does when a non-null cell fails to parse under the dtype that inference locked in for its column — in practice a value past the inference window that doesn't fit (e.g. a String in a column inferred Int from its first rows).

    • Raise (every reader's default) — surface ParseError(Cell(...)), failing the whole read. The strict, lossless behaviour: a malformed cell is never silently dropped.
    • Null — downgrade the offending cell to a null cell and keep going, the resilient behaviour. The column keeps its inferred dtype; only the unparseable cells become null.

    Shared by CsvReadOptions and JsonReadOptions and consumed in build_typed_column's parse-failure branch, so the three readers agree on the policy.

    OnParseError::equal

    OnParseError::not_equal

    fn OnParseError::not_equal(x : OnParseError, y : OnParseError) -> Bool

    ParquetCodec

    pub(all) enum ParquetCodec {
    Uncompressed
    Snappy
    Gzip
    } derive(Eq,
    Debug
    )

    The compression a written parquet file carries (the reader takes every codec it can decode; this names the writer's).

    ParquetCodec::equal

    ParquetCodec::not_equal

    fn ParquetCodec::not_equal(x : ParquetCodec, y : ParquetCodec) -> Bool

    format_csv

    Render a DataFrame as a CSV string.

    • Header (when options.header == true): column names joined by options.delimiter, each quoted only when it would otherwise be ambiguous.
    • Each row: cells joined by options.delimiter, terminated by options.line_terminator (LF by default). Null cells are written as options.null_value; other cells render via Scalar::to_string.
    • Quoting: a cell containing the delimiter, a double quote, \r, or \n is wrapped in double quotes; interior double quotes are doubled (" → ""). Cells that need no quoting are written verbatim so the output matches the simple "no quotes" CSV idiom whenever possible. Two cells are quoted anyway: in a single-column frame an empty cell (or an empty column name) is written as "" rather than a bare blank, so the row is not a blank line the reader would skip; and a first field opening with a byte-order mark is quoted so the mark cannot be read as part of the file's own preamble.
    • Round-trip caveat: cells render via Scalar::to_string, so a Float whose value is a whole number is written without a fractional part (2.0 → 2) and is re-inferred as Int on read — the same dtype narrowing the JSON writer documents. The rider dtypes write their value text (Date / Timestamp as ISO text, Decimal as its positional / scientific value form), which inference still never picks up — a written-back rider column reads as String / Float unless a dtypes pin names the dtype, and the riders' read parsers accept exactly the text this writer emits, so the pinned round trip is lossless. Negative zero is one such whole value: -0.0 writes as 0, so its sign (observable under division) does not survive the round-trip. A String cell with significant leading / trailing whitespace is written bare (only the delimiter, a quote, \r, or \n force quoting), so this reader round-trips it (trim_spaces off), but an RFC-4180 consumer that trims surrounding whitespace may drop it. A String cell whose text equals a reader null token — the default null_value is the empty string "", so this includes empty strings, plus any custom null_values entry — is read back as null and cannot be distinguished from a true null. A String cell whose text parses as another dtype is likewise re-inferred on read: inference is content-based with no header type hints, so a column of numeric-looking strings ("01", "2") returns as Int / Float — dropping any leading zeros — and "true" / "false" as Bool, the dtype-from-content narrowing inherent to typeless CSV. Quote / escape handling is otherwise round-trip safe.
    • When sanitize_formulas is true, a String cell beginning with =, +, -, @, tab, or carriage return is prefixed with an apostrophe before CSV quoting. This opt-in, intentionally lossy transformation prevents spreadsheet applications from interpreting such cells as formulas. It does not affect headers, nulls, numbers, booleans, or other strings; the default false preserves exact output.
    • Raises InvalidOperation if options.delimiter is a double quote or a line terminator (\n / \r): those collide with the hard-coded quote character and the row terminator, so no escaping could make the output frame fields unambiguously.
    • Raises InvalidOperation for an N×0 frame — rows but no columns — with N > 0. CSV frames a row by its fields, so a row with no fields is an empty line, and an empty line is exactly what the reader skips: such a frame would write as N blank lines and read back as the empty 0×0 frame, losing every row without an error. The format has no spelling for "a row with zero fields", so the write is refused rather than silently made lossy — the delimiter refusal's refuse-don't-corrupt stance, applied to the shape. The column-less 0×0 frame has no rows to lose and still writes: the empty string, or the lone \n of its (field-less) header row.

    format_json

    fn format_json(df :
    DataFrame
    ) -> String

    Render a DataFrame as a JSON records string [ {...}, ... ].

    Per cell:
    • Null → JSON null
    • Int → JSON number (no fractional part)
    • Float→ JSON number for finite values. NaN / ±Infinity have no JSON literal, so they are emitted as null to keep the output valid JSON — a round-trip reads a non-finite cell back as a null.
    • Bool → JSON true / false
    • String → JSON string (escaping ", \, control chars via the builtin stringifier — we deliberately do not roll our own escape so any future Unicode spec tweaks land transparently)
    • Date / Timestamp / Decimal → JSON string holding the cell's value-form rendering (ISO calendar text / ISO instant / the decimal value spelling); the readers never infer these dtypes, so an unpinned round-trip reads the column back as String / Float — a dtypes pin reads the string back into its rider dtype, text being the riders' one carrier in a format with no native type for them.

    Keys appear in the column declaration order, preserved by the builtin Map (linked-hash-map) used for each record object.

    format_ndjson

    fn format_ndjson(df :
    DataFrame
    ) -> String

    Render a DataFrame as an NDJSON string: one flat JSON object per row, each terminated by \n (including the last, matching the CSV writer's per-row LF). A 0-row frame renders the empty string.

    Per-cell conventions are shared with format_json via scalar_to_json: Null → null; Int → JSON number (no fractional part; exact across the full Int64 range via the preserved repr); finite Float → JSON number, non-finite (NaN / ±Infinity) → null so each line stays valid JSON; Bool → true / false; String → escaped JSON string; Date / Timestamp / Decimal → JSON string holding the value-form rendering, which a dtypes pin reads back into its rider dtype (inference never picks these up on its own). Keys appear in df.columns() order, preserved by the linked-hash-map Map backing each record object.

    parse_csv_str

    fn parse_csv_str(content : String, options? : CsvReadOptions, projection? : Array[String]) ->
    DataFrame
    raise
    DataError

    Parse a CSV-encoded string into a DataFrame. The pipeline is:
    1. NyaCSV tokenises the text into headers + rows. NyaCSV always treats the first row as a header, so the has_header = false case re-folds that row into the data section and synthesises column1, column2, … names.
    2. Per-column type inference walks the first infer_schema_rows rows in order Int → Float → Bool → String (a null cell within them is skipped but still counts toward the window). The first option that accepts every probed cell wins; a column with no non-null probes lands on String (no information to disambiguate). A column named in options.dtypes skips this pass and locks in its pinned dtype instead.
    3. Null mapping replaces any raw cell whose verbatim string sits in null_values with None. The mapping runs after tokenisation, so quoted empty cells ("") and bare empty cells are both honoured.
    4. Each column is assembled into a typed Series and the result is wrapped through DataFrame::from_parts (an empty input short-circuits to DataFrame::DataFrame([]) before this point).

    Caveat — integer text past Int64. The Int probe accepts a cell only as a base-10 literal inside the signed Int64 range; an integer literal one past it (9223372036854775808 = 2^63) is still a plain Double literal, so it tips its column to Float — the value keeps its magnitude as the nearest Double (exact for 2^63 itself, rounded for neighbors like 2^63 + 1), and the narrowing is silent: one out-of-range cell retypes the whole column through the Int → Float → Bool → String ladder. The JSON family's large-Int64 caveat (json_core's Caveat 2) is the writer-side sibling; CSV has no writer side to it — an Int column writes exact decimal text, so this is a read-side fact of the inference ladder alone. Pinning dtypes = { "col": Int } does not rescue the value: the cell then fails the pinned parse and follows on_parse_error.

    Raises:
    • DuplicateColumn(name) — two headers share a name.
    • InvalidOperation — options.dtypes names a column the input does not carry, or pins a dtype that has no read parser (anything but Int / Float / Bool / String / Date / Timestamp / Decimal).
    • ParseError(Message(...)) — when strict_quotes is true, the input contains an unterminated quoted field, text after a closing quote, or a quote inside an unquoted field; or — when options.strict_column_count is true — a data row's cell count differs from the header's (reported as row N: expected C columns, got G, 1-based over the data rows).
    • ParseError(Cell(...)) — a non-null cell does not parse under the inferred dtype for its column (typically because a sample row outside the inference window is malformed for the inferred type), unless options.on_parse_error is Null, which downgrades that cell to a null instead of failing the read.
    • Whatever DataFrame::from_parts propagates — DuplicateColumn / LengthMismatch / a negative-height InvalidOperation, none of which can actually fire here (uniqueness is checked above; every column is built off the same non-negative rows.length()).

    By default, tokenisation keeps NyaCSV's lenient quote handling. An unterminated quoted field at end-of-input is read as a complete field (1,"unclosed → last cell unclosed); text after a closing quote is folded into the same field ("ab"cd → abcd); and a lone quote inside an unquoted field is kept literally (ab"cd → ab"cd). A strict RFC-4180 reader rejects all three; CsvReadOptions::CsvReadOptions(strict_quotes=true) runs a linear validation pass before tokenisation and rejects them as ParseError.

    projection narrows the read to the named columns — the same knob the lazy scan_csv source's projection pushdown rides. None (the default) builds every column; Some(names) builds only the columns whose header name appears in names, in the file's own header order, leaving the rest uninferred, unparsed, and unmaterialised. A requested name that matches no header is silently ignored (lenient projection — the lazy scan driver relies on it when it hands down its pruned column list), and a projection matching no header builds no column at all and yields the N×0 frame — the file's rows are still counted, so a downstream head / slice bounds-checks against the real height. Whole-input checks (strict quote validation, the empty-input short-circuit, duplicate-header rejection, the ragged-row guard) run before the projection filter and so are unaffected by it; the one behavioural difference is the point of the knob — a parse error confined to a dropped column is not raised, that column is never parsed.

    parse_json_str

    Parse a JSON records string ([ {...}, ... ]) into a DataFrame.

    @json.parse produces the Json AST; a top-level value that is not an array surfaces as ParseError. The array's elements are then handed to frame_from_json_records, which validates each is an object, collects headers in first-seen order across all records, infers one dtype per column, and materialises the frame. An empty array — like empty or whitespace-only input — yields a 0×0 frame.

    Raises:
    • ParseError(Message(...)) — malformed JSON, a top-level value that is not an array, a record that is not an object, or nesting deeper than 512 brackets (refused by a pre-scan before the parse, naming the line / column — the reader's own bound, in place of the parser's position-less default-depth refusal).
    • InvalidOperation — options.dtypes names a column the input does not carry, or pins a dtype that has no read parser (anything but Int / Float / Bool / String / Date / Timestamp / Decimal).
    • ParseError(Cell(...)) — a non-null cell does not fit the column's inferred dtype, unless options.on_parse_error is Null, which downgrades that cell to a null instead.
    • Whatever DataFrame::from_parts propagates (duplicate-header is pre-empted upstream; length-mismatch cannot fire because every column is built off records.length()).

    parse_ndjson_str

    fn parse_ndjson_str(content : String, options? : JsonReadOptions, projection? : Array[String]) ->
    DataFrame
    raise
    DataError

    Parse an NDJSON string (one JSON object per line) into a DataFrame.

    Pipeline:
    1. Split content on \n. Each non-blank line is parsed with @json.parse; a malformed line surfaces as ParseError(Message("line N: ...")) (1-based). Blank / whitespace-only lines are skipped, so the writer's trailing newline — and any incidental blank lines — never produce phantom records.
    2. The parsed values are handed to frame_from_json_records, which validates each is an object, collects headers in first-seen order across all records (sparse records → null cells), infers one dtype per column, and materialises the frame under per-column rules shared with parse_json_str.

    Empty input — or input that is entirely blank lines — yields a 0×0 frame, matching parse_json_str's empty-array behaviour.

    Raises:
    • ParseError(Message(...)) — a malformed line, a line whose value is not a JSON object, or a record nesting deeper than 512 brackets (refused by a pre-scan before the parse, naming the physical line and column — the reader's own bound, in place of the parser's position-less default-depth refusal).
    • ParseError(Cell(...)) — a non-null cell does not fit its inferred dtype, unless options.on_parse_error is Null, which downgrades that cell to a null instead.
    • Whatever DataFrame::from_parts propagates.

    projection narrows the read to the named columns — the same knob the lazy scan_ndjson source's projection pushdown rides. None (the default) builds every column; Some(names) builds only the columns whose header name appears in names, in first-seen header order. Every line is still parsed and record validation runs before the column filter, so a projected read fails on a malformed or non-object line exactly as a full read does; the one behavioural difference is the point of the knob — a parse error confined to a dropped column is not raised, that column is never built.

    parse_parquet

    fn parse_parquet(bytes : Bytes, projection? : Array[String]) ->
    DataFrame
    raise
    DataError

    Parse parquet bytes into a frame — the string-level entry's binary counterpart (what read_parquet hands the codec, exposed for in-memory bytes). The same contract as read_parquet's.

    read_csv

    Read a CSV file. options defaults to CsvReadOptions::CsvReadOptions(), so read_csv(path) is the default-options read. IOError from the file system surfaces as raise IoError(message). CsvReadOptions::CsvReadOptions(strict_quotes=true) rejects malformed quoting before NyaCSV tokenisation, exactly as parse_csv_str does.

    read_json

    Read a JSON records file. options defaults to JsonReadOptions::JsonReadOptions(), so read_json(path) is the default-options read. Filesystem errors surface as raise IoError(message).

    read_ndjson

    Read an NDJSON file. options defaults to JsonReadOptions::JsonReadOptions(), so read_ndjson(path) is the default-options read. Filesystem errors surface as raise IoError(message).

    read_parquet

    fn read_parquet(path : String, projection? : Array[String]) ->
    DataFrame
    raise
    DataError

    Read a parquet file into a frame: the footer's schema names the dtypes, each column chunk decodes its pages, and the projection (every column when projection? is omitted) rides into the chunk walk — unprojected columns are never parsed. The projection is lenient like the text readers': a name the file does not carry builds no column (a projection matching no column yields the file's rows over zero columns), and whichever expression references the missing name raises ColumnNotFound, the same error a full read plus a select would. Also raises Unsupported for a dtype or encoding the mapping does not carry (a FLOAT column would narrow; a nested or dictionary-only page shape decodes or names itself) and ParseError for a malformed file.

    scan_csv

    fn scan_csv(path : String, options? : CsvReadOptions) ->
    LazyFrame

    The lazy CSV source: scan_csv(path) builds a LazyFrame whose leaf is a deferred read of path — the push-down-aware counterpart of eager read_csv. Nothing is read or parsed until collect: the builder is total, like every other LazyFrame constructor, so a missing file or a malformed CSV only surfaces then (as the eager reader's IoError / ParseError / DuplicateColumn). It is not a streaming read — the reader still tokenises the whole file, and streaming it is tracked as future work.

    The payoff over @frame.LazyFrame::LazyFrame(read_csv(path)) is that this leaf absorbs both push-downs, so the work it skips is work the eager pipeline does:
    • projection — the optimizer narrows the leaf to the columns the pipeline provably consumes, and only those are parsed, so scan_csv("sales.csv").select([col("region"), col("revenue")]).collect() never builds the columns it drops;
    • predicate — a filter sitting on the leaf moves into the read: the reader builds the predicate's columns, asks which rows survive, then parses the remaining columns for the survivors alone. Only the first such filter is absorbed; a second stays a node above the scan.

    Both prune cells an eager read-then-filter would have parsed, which is the one way a narrowed scan diverges from a full eager read: a ParseError confined to a dropped column, or to a row the predicate drops in a column the predicate does not read, does not surface. Dtype inference still walks the whole file, so dtypes and the surviving cells match the eager read exactly. The pin that fences this back is the temporal family (Date / Timestamp): temporal + / - refuse on instants leaving the microsecond range, so above a scan whose pin carries one, the value-fence holds any predicate or stage expression with such an operation in place — a sunk one would prune away the very rows the refusal lives on, and a plan that fails to collect must still fail optimized. A Decimal pin needs no fence: the decimal operations carry NaN and ±∞ as values and never raise, so a sunk predicate cannot change which rows collect.

    options (delimiter, header, null strings, inference window, parse-error policy, strict quotes, dtype pins, …) defaults to CsvReadOptions::CsvReadOptions(), mirroring eager read_csv. It is captured into the plan and applied by the reader at collect time; projection push-down narrows which columns those options parse, never which options apply. The projection starts None (read every column) — only the optimizer fills it.

    scan_json

    fn scan_json(path : String, options? : JsonReadOptions) ->
    LazyFrame

    The lazy JSON source: scan_json(path) builds a LazyFrame whose leaf is a deferred read of path — the push-down-aware counterpart of eager read_json, for the single top-level array of records ([{...}, {...}]). Like every LazyFrame constructor it is total: nothing is read or parsed until collect, so a missing file, malformed JSON, or a non-object record only surfaces then (as the eager reader's IoError / ParseError).

    The one-way shape of the format sets what the push-downs can prune: the top-level array must be parsed whole to find its records, so the pruning both push-downs bring is at the assembly — projection leaves the dropped columns uninferred and unbuilt, and the first predicate sitting on the leaf builds only the surviving rows' cells past the predicate's own columns. The parse itself is never skipped, which is also why this is not a streaming read. A ParseError confined to a dropped column or to a dropped row therefore does not surface, and the surviving cells and dtypes match an eager read exactly — the contract the other two scan sources honour, at the granularity this format allows.

    options defaults to JsonReadOptions::JsonReadOptions(), mirroring eager read_json, and is captured into the plan and applied at collect time; projection push-down narrows which columns those options parse, never which options apply. A Date / Timestamp pin fences the temporal value half of the push-downs exactly as it does for scan_csv, read off the same options field; a Decimal pin carries no value fence.

    scan_ndjson

    fn scan_ndjson(path : String, options? : JsonReadOptions) ->
    LazyFrame

    The lazy NDJSON source: scan_ndjson(path) builds a LazyFrame whose leaf is a deferred read of path — the push-down-aware counterpart of eager read_ndjson, and the line-oriented sibling of scan_csv. Like every LazyFrame constructor it is total: nothing is read or parsed until collect, so a missing file or a malformed line only surfaces then (as the eager reader's IoError / ParseError). It is not a streaming read — the reader still parses every line — and it absorbs the same two push-downs scan_csv documents: projection (only the consumed columns are built) and the first predicate sitting on the leaf (the surviving rows' cells are the only ones built past the predicate's own columns). So a parse error confined to a dropped column, or to a dropped row, does not surface; the surviving cells and the inferred dtypes match an eager read exactly. (The single-array shape has its own source, scan_json.)

    options (inference window, parse-error policy, dtype pins, …) defaults to JsonReadOptions::JsonReadOptions(), mirroring eager read_ndjson. It is captured into the plan and applied by the reader at collect time; projection push-down narrows which columns those options parse, never which options apply. The projection starts None (read every column) — only the optimizer fills it. A Date / Timestamp pin fences the temporal value half of the push-downs exactly as it does for scan_csv, read off the same options field; a Decimal pin carries no value fence (its operations are total).

    scan_parquet

    fn scan_parquet(path : String) ->
    LazyFrame

    The lazy parquet source: scan_parquet(path) builds a LazyFrame whose leaf is a deferred read of path — the push-down-aware counterpart of eager read_parquet, and the columnar twin of the text scans. Nothing is read until collect (the builder is total). The projection push-down is where a columnar source pays: the optimizer narrows the leaf to the columns the pipeline consumes, and only those chunks decode — a select of two columns of a wide file never touches the other chunks' bytes at all. The predicate push-down moves the filter into the read as a post-decode filter over the projected frame (the row pruning a columnar file without row-group statistics can offer); a ParseError in an unprojected column does not surface, exactly like the text scans' dropped columns. The dtypes come from the footer's schema, so a narrowed scan matches the eager read exactly — and the footer can name temporal columns no plan-time fact can rule out (reading it at build would break the builder's totality), so this source takes the temporal value-fence's conservative arm: a predicate or stage expression carrying a temporal-checked operation stays above the scan, trading that push-down for a failing plan still failing. A decimal column needs no fence — its operations are total over values.

    write_csv

    Write a DataFrame to a CSV file. options defaults to CsvWriteOptions::CsvWriteOptions(), so write_csv(path, df) is the default-options write. IOError from the file system surfaces as raise IoError(message). A string cell (or column name) holding an unpaired UTF-16 surrogate is refused with raise InvalidOperation — the UTF-8 file encoding would swallow the following delimiter and silently shift every later cell boundary. CsvWriteOptions::CsvWriteOptions(sanitize_formulas=true) applies the same spreadsheet-safety transformation as format_csv before writing. Rendering runs through format_csv first, so its refusals come first too — an unrepresentable delimiter and the N×0 shape (rows but no columns) both raise InvalidOperation before the file is opened, leaving nothing written.

    write_json

    Write a DataFrame to a JSON records file. Filesystem errors surface as raise IoError(message). A string cell (or column name) holding an unpaired UTF-16 surrogate is refused with raiseInvalidOperation — the UTF-8 file encoding would swallow the following code unit and corrupt the JSON framing.

    write_ndjson

    Write a DataFrame to an NDJSON file. Filesystem errors surface as raise IoError(message). A string cell (or column name) holding an unpaired UTF-16 surrogate is refused with raise InvalidOperation — the UTF-8 file encoding would swallow the following code unit and corrupt the line framing.

    write_parquet

    Write a frame as one parquet file. Raises Unsupported for a column whose dtype the mapping does not carry (a Null column) and InvalidOperation for a Date day count outside the INT32 the parquet DATE annotation rides, for a Decimal cell whose NaN / ±∞ shape has no fixed-point spelling, and for a decimal column past the 38-digit payload window.