inferCsvSchema

fnSchema inferCsvSchema(const(char)[] text, CsvInferPolicy policy = CsvInferPolicy.init)

Infers the schema of CSV text: the opt-in alternative to the explicit schema (ADR-2026-10-24-19). Every sampled cell contributes a candidate; per column the candidates join in the lattice with STRING on top (an all-null column is STRING - there is no Null kind); overrides force kinds per column and skip inference. The default sample is the full text, so the schema is a pure function of the bytes; a finite sampleRows scans only the first data rows. Two passes over memory, never a file re-seek; inference happens at source construction and adds no streaming capability.

Parameters

textthe CSV text
policythe inference policy

Returns

the inferred schema, Schema([]) for empty text.

Throws

DataFrameException on duplicate header names, header-only

schema-width conflicts (ragged first row), an override naming a missing column or position, an override with a kind the reader does not support, or a walked row whose field count differs from the width (line, got and expected counts).

Example:

auto schema = inferCsvSchema("a,b\n1,x\n");
assert(schema.fields()[0] == Field("a", DataType.INT64));
assert(schema.fields()[1] == Field("b", DataType.STRING));