pola-rs/polars · error · ValueError

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

Error message

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

What it means

When read_parquet is dispatched to pyarrow (use_pyarrow=True), the row-limit parameter n_rows is not honored by the pyarrow path, so Polars rejects the combination with a ValueError instead of silently ignoring the limit.

Solutions

  1. Drop n_rows and rely on pyarrow_options (e.g. pyarrow_options={'filters': ...}) if applicable
  2. Remove use_pyarrow=True so Polars' native reader honors n_rows
  3. Use pl.scan_parquet(...).head(n).collect() to limit rows natively

Example fix

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

Strategy: validation

Validate before calling

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

Prevention

When it happens

Trigger: pl.read_parquet(..., use_pyarrow=True, n_rows=<int>) — any non-None n_rows together with use_pyarrow=True.

Common situations: Code that adds use_pyarrow=True for compatibility while already limiting rows; debugging memory issues by adding a row cap to an existing pyarrow-dispatched read.

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/3760fc5d164c830e. Report an issue: GitHub.

Appendix: source

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

    """
    row_index = parse_row_index_args(row_index_name, row_index_offset)
    del row_index_name
    del row_index_offset

    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,

View on GitHub (pinned to fe841f959e)