pola-rs/polars · error · ParameterCollisionError
cannot specify columns in both `schema_overrides` and…
Error message
cannot specify columns in both `schema_overrides` and `read_options['dtypes']`
What it means
This ParameterCollisionError fires when the same column(s) get a dtype from two places at once: the top-level `schema_overrides` argument of read_excel and `read_options['schema_overrides']` (formerly `dtypes`) forwarded to the internal read_csv call via the xlsx2csv path. Polars refuses the ambiguous overlapping specification rather than guessing which wins.
Solutions
- Remove the column dtype map from `read_options` and specify all overrides in the top-level `schema_overrides` parameter.
- Or keep overrides only in read_options and drop the top-level schema_overrides — pick one location.
- Ensure the key sets are disjoint if you genuinely need both (different columns in each).
Example fix
// before
pl.read_excel('f.xlsx', engine='xlsx2csv', schema_overrides={'a': pl.Utf8}, read_options={'schema_overrides': {'a': pl.Int64}})
// after
pl.read_excel('f.xlsx', engine='xlsx2csv', schema_overrides={'a': pl.Utf8}) Defensive patterns
Strategy: validation
Validate before calling
ro = read_options.get('schema_overrides', {})
overlap = set(schema_overrides or {}).keys() & set(ro).keys()
if overlap:
raise ValueError(f'column dtype overrides specified twice: {sorted(overlap)}') Try / catch
try:
df = pl.read_excel(path, engine='xlsx2csv', schema_overrides=overrides, read_options=read_options)
except pl.exceptions.ParameterCollisionError as e:
log.error('Duplicate column overrides: %s', e)
raise Prevention
- Specify column dtypes in exactly one place (prefer top-level schema_overrides)
- When merging option dicts, merge their schema_overrides maps explicitly and check for key collisions
- Write a small wrapper function that owns all read_options construction
When it happens
Trigger: `pl.read_excel(..., engine='xlsx2csv', schema_overrides={'col': pl.Utf8}, read_options={'schema_overrides'/'dtypes': {'col': pl.Int64}})` where the key sets intersect (set intersection is non-empty).
Common situations: Merging user-supplied options dicts with defaults that both contain column dtype maps; passing schema_overrides at both levels after migrating from the old `dtypes` name; helper functions that blindly forward kwargs.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- can not match overlapping patterns when leftmost == True
- cannot create a second
- cannot exclude by both column name and dtype
- cannot specify both `columns` and `read_options["columns"]`
- cannot specify both `columns` and…
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/21ffc0c8c95b8b4b.
Report an issue: GitHub.
Appendix: source
Thrown at py-polars/src/polars/io/spreadsheet/functions.py:937
# otherwise rewind the buffer and parse as csv
csv.seek(0)
if read_options is None:
read_options = {}
date_cols = []
if schema_overrides:
if csv_dtypes := read_options.get("dtypes", {}):
msg = "the `dtypes` parameter for `read_csv` has been renamed to `schema_overrides`."
raise TypeError(msg)
csv_schema_overrides = cast(
"SchemaDict", read_options.get("schema_overrides", csv_dtypes)
)
if set(csv_schema_overrides).intersection(schema_overrides):
msg = "cannot specify columns in both `schema_overrides` and `read_options['dtypes']`"
raise ParameterCollisionError(msg)
overrides, schema_overrides = {**csv_schema_overrides, **schema_overrides}, {}
for nm, dtype in overrides.items():
if dtype != Date:
schema_overrides[nm] = dtype
else:
date_cols.append(nm)
read_options = read_options.copy()
read_options["schema_overrides"] = schema_overrides
df = _drop_null_data(
df=read_csv(
csv,
separator=separator,
**read_options,
),
raise_if_empty=raise_if_empty,View on GitHub (pinned to fe841f959e)