What this thread does
Do first: inspect every file's ParquetFile.schema_arrow and call pyarrow.unify_schemas(schemas, promote_options="default") before constructing the common dataset.
Short answer
As of November 2026, Apache Arrow/PyArrow 26.0.1 is the reference. An explicit Dataset schema prevents schema inference from the source. Preflight all fragments and partition types, reject unapproved field/type changes, then pass a deliberately chosen Arrow Schema into dataset using its schema argument. Source
Choose / don't choose
- Type conflicts: choose rejection and a named migration. Don't use
"permissive"promotion merely to make a mixed historical dataset read. - Explicit partition schema: choose for leading-zero IDs, stable integer widths, dates or mixed directory tokens; inference is acceptable only when its types are intentionally the contract (partitioning).
Not for: Polars scan setup; see polars-read-parquet-or-scan-parquet-setup.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
dataset(schema=...) | An approved pa.Schema, e.g. pa.schema([("id", pa.int64()), ("region", pa.string())]); default None infers | PyArrow current docs, November 2026 | dataset API |
unify_schemas(promote_options=...) | "default" default rejects differing non-null types; null may merge with another type. "permissive" promotes compatible types | PyArrow current docs, November 2026 | unify API |
partitioning(schema=..., flavor=...) | For region=001, choose pa.schema([("region", pa.string())]) with flavor="hive"; default schema None; inference requires field_names and/or flavor | PyArrow current docs, November 2026 | partition API |
partition_base_dir | Explicit dataset root when a supplied path list needs that prefix stripped before partition parsing | PyArrow current docs, November 2026 | dataset API |
partitioning(dictionaries=...) | Dictionary-typed partition fields require all allowed values; "infer" discovers them | PyArrow current docs, November 2026 | partition API |
Order of operations
1. Inventory intended Parquet paths before a dataset with the target schema is built. For each file read pq.ParquetFile(path).schema_arrow; retain path-to-schema provenance and close opened readers (ParquetFile). 2. Compare each field name/type against the approved contract and group paths by schema. Preflight payload schemas separately from directory partition fields, which may be absent from file payloads. Include duplicate names, nullability and metadata in the application's policy. 3. Run strict-default unification. If it fails, pair each fragment with the expected payload schema to locate field/type conflicts; report the file and both types. Under this mode two fields with different types will fail merging by default. Null is the explicit exception (unify rules). 4. Decide whether each absent/new field is an allowed nullable addition or an error. Unification returns a union and inherits metadata by first occurrence, so also compare metadata deliberately; don't equate a successful union with identical schemas. 5. Construct pyarrow.dataset.dataset with explicit schema, format, partitioning and partition_base_dir arguments only after acceptance. Include approved partition fields in the dataset schema, with types matching part. Read representative batches from every schema group and compare types, null counts and partition values (dataset API, guide). 6. Quarantine conflicting files or rewrite them through an explicit, separately reviewed conversion; keep source values for conversions that can lose precision or leading zeros.
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
ArrowInvalid during schema unification | Same field name has incompatible types, or an input has duplicate field names | Identify paths by per-file preflight, reject duplicates/conflicts, and migrate explicitly | unify API |
| New fields missing from the read view (symptom) | The report concerns Parquet files with different schemas | Inspect all file schemas, approve additions and pass the full intended schema; don't rely on one inferred view | multi-schema report, dataset API |
| Partition dictionary parse failure (symptom) | Dictionary-field entries must include every column value | Supply the complete approved dictionary or deliberately use inference | partition API |
The dated multi-schema discussion motivates schema merging; the exact current rejection/promotion contract comes from the API above.
Missing
- No fragment schemas or approved evolution policy are identified; a safe common schema and migration cannot be inferred.
- Footer compatibility does not prove every data value can satisfy the final read contract.
Checked
2026-11-12; release, dataset/unification/ParquetFile/partition references, dataset guide and dated multi-schema issue read. No Parquet reads or conversion commands executed.
Started from a post by @Apache Arrow, packaged by the editor. Original post