pola-rs/polars · error · ValueError

`schema` cannot be used with `use_pyarrow=True`

Error message

`schema` cannot be used with `use_pyarrow=True`

What it means

An explicit schema parameter is only supported by Polars' native parquet reader; when use_pyarrow=True the read is delegated to pyarrow, which has no equivalent hook in this dispatch path, so passing schema triggers a ValueError.

Solutions

  1. Remove schema when using use_pyarrow=True
  2. Drop use_pyarrow=True and keep the explicit schema
  3. Cast after reading: df.cast(schema) or df.with_columns(...) post-read

Example fix

// before
pl.read_parquet('f.parquet', use_pyarrow=True, schema=myschema)
// after
pl.read_parquet('f.parquet', schema=myschema)
Defensive patterns

Strategy: validation

Validate before calling

if use_pyarrow and schema is not None:
    raise ValueError('schema cannot be used with use_pyarrow=True')

Try / catch

try:
    df = pl.read_parquet(src, use_pyarrow=True, schema=s)
except ValueError:
    df = pl.read_parquet(src, schema=s)  # native path honors schema

Prevention

When it happens

Trigger: pl.read_parquet(..., use_pyarrow=True, schema=<Schema>) — any non-None schema combined with use_pyarrow=True.

Common situations: Overriding/upcasting column dtypes at read time while also dispatching to pyarrow; code migrated from native reads that added use_pyarrow=True later.

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


AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18). Data as JSON: /api/errors/02c15c4be60927b7. Report an issue: GitHub.

Appendix: source

Thrown at py-polars/src/polars/io/parquet/functions.py:251

    if schema is not None:
        msg = "the `schema` parameter of `read_parquet` is considered unstable."
        issue_unstable_warning(msg)

    if hive_schema is not None:
        msg = "the `hive_schema` parameter of `read_parquet` is considered unstable."
        issue_unstable_warning(msg)

    # Dispatch to pyarrow if requested
    if use_pyarrow:
        if n_rows is not None:
            msg = "`n_rows` cannot be used with `use_pyarrow=True`"
            raise ValueError(msg)
        if include_file_paths is not None:
            msg = "`include_file_paths` cannot be used with `use_pyarrow=True`"
            raise ValueError(msg)
        if schema is not None:
            msg = "`schema` cannot be used with `use_pyarrow=True`"
            raise ValueError(msg)
        if hive_schema is not None:
            msg = (
                "cannot use `hive_partitions` with `use_pyarrow=True`"
                "\n\nHint: Pass `pyarrow_options` instead with a 'partitioning' entry."
            )
            raise TypeError(msg)

        df = _read_parquet_with_pyarrow(
            source,
            columns=columns,
            storage_options=storage_options,
            pyarrow_options=pyarrow_options,
            memory_map=memory_map,
        )

        if row_index is not None:
            name, offset = row_index
            df = df.with_row_index(name, offset)

View on GitHub (pinned to fe841f959e)