What this thread does
Do first: configure ParseOptions(explicit_schema=schema, unexpected_field_behavior="error") and confirm the export is one JSON object per line.
Short answer
As of November 2026, this card targets PyArrow 21.0.0, July 17, 2025. The native reader consumes JSON Lines; a top-level array needs conversion. Small arrays can use Python’s JSON decoder; large arrays need incremental conversion or an exporter change.
Choose / don't choose
- Strict daily contract: choose explicit_schema plus error on new fields; unknown columns require a schema decision. Do not silently infer a new contract every day.
- Append: choose unique ingest filenames only for disjoint input with a durable ingest ledger; a different name on replay appends duplicates.
- Complete-day replacement: choose one complete day per replacement operation; never delete the published partition while readers discover it.
Not for: Polars read/scan selection; see polars-read-parquet-or-scan-parquet-setup.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
ParseOptions.explicit_schema | The canonical Arrow Schema; default None. Apply required-field/null checks separately | PyArrow baseline above | parse options |
ParseOptions.unexpected_field_behavior | "error" for strict evolution; default "infer"; "ignore" intentionally discards extra fields | PyArrow baseline above | parse options |
write_dataset.partitioning | Explicit typed ds.partitioning with an explicit schema and flavor="hive"; use identical key types when reading | PyArrow baseline above | partition schemas |
write_dataset.basename_template | Default "part-{i}." + format.default_extname; choose a unique ingest prefix for append and stable names within an immutable generation | PyArrow baseline above | writer |
write_dataset.existing_data_behavior | "error" raises an error if any data exists in the destination; "overwrite_or_ignore" overwrites equal names; "delete_matching" removes each encountered partition once per call | PyArrow baseline above | writer |
max_rows_per_file | Default 0 means unlimited; choose floor(target file bytes / measured encoded bytes per row) | PyArrow baseline above; derived sizing policy | writer |
max_rows_per_group / min_rows_per_group | Maximum default 1024*1024, minimum default 0; choose a positive group target from decoded-row bytes and query footprint, with group target <= file target | PyArrow baseline above; derived sizing policy | writer |
Order of operations
1. Validate every JSON file against the canonical schema before publication, with reading one JSON batch at a time using open_json. Check required fields and a non-null export-day value separately; preserve a file/row rejection report. Missing fields must not silently pass a business completeness check (JSON reading; batch reader). 2. Use an explicit partition key type, such as string for canonical day text, on both writer and reader. Check each individual file schema and directory key types before combining files; a declared reader view is not proof that stored data has the intended type. 3. Write all batches for that day to a fresh unpublished generation in one write_dataset call. Serialize writers for the same logical day (writer behavior). 4. Reopen the completed generation without imposing a replacement data schema; compare its logical schema with Schema.equals, source counts, unique keys, null counts, day membership and totals. Partition fields are added back to the resulting table when scanning the dataset. Validate file footers and row groups; do not rely on row order (dataset reader; schema comparison). 5. Publish by switching a separately managed catalog/manifest pointer that readers resolve once per snapshot, using an atomic or conditional operation supported by the storage system. Keep old generations until readers finish. This is an application design derived from the dataset API’s absence of transactions; moving/deleting files in an actively discovered directory is not an atomic swap (transaction limits). 6. Measure representative encoded and decoded bytes per row, then derive file and row-group targets. Avoid files smaller than 20MB or larger than 2GB; query selectivity, variable-width rows, writer buffering and concurrent scans determine the actual group budget. Inspect emitted files/groups before promoting the generation (layout guidance).
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
JSON parse error: Column(/a/b) changed from number to string in row 1 | Mixed JSON types; a literal slash in a key can confuse a downstream recovery path | Inspect the actual raw key and per-file schema; normalize the field to the declared type or reject it before writing | Datasets report |
Unable to merge: Field part has incompatible types: large_string vs string | The report describes incompatible types large_string vs string in Field part | Compare file fields with explicit partition schema; align the canonical type through conversion/rewrite, not blind schema imposition. TomAugspurger reported this July 23, 2025 | Arrow report |
But this overwrites the original | The report says the original was overwritten | Use unique append basenames or a complete replacement policy; phpsxg’s December 5, 2022 report illustrates the distinction | append report |
Missing
- Storage atomicity, row widths, daily volume and reader access patterns are unspecified; no universal row counts or atomic filesystem rename can be prescribed. Schema types alone do not enforce required business fields or uniqueness.
Checked
2026-11-12; Apache Arrow; 21.0.0 release; JSON/ParseOptions/open_json, dataset/writer/schema references, phpsxg and TomAugspurger reports and the Datasets slash-key report read. No application commands were executed.
Related references: reference 1.
Started from a post by @phpsxg, packaged by the editor. Original post