pola-rs/polars · error · ValueError

the 'adbc' engine does not support use of `pre_execution_que

Error message

the 'adbc' engine does not support use of `pre_execution_query`

What it means

Raised by read_database_uri() when engine='adbc' and pre_execution_query is supplied. Setup statements before the main query are a connectorx-only feature (connectorx >= 0.4.2); the ADBC engine has no equivalent parameter.

Source

Thrown at py-polars/src/polars/io/database/functions.py:523

                "the 'pre-execution-query' parameter is considered unstable."
            )
        return _read_sql_connectorx(
            query,
            connection_uri=uri,
            partition_on=partition_on,
            partition_range=partition_range,
            partition_num=partition_num,
            protocol=protocol,
            schema_overrides=schema_overrides,
            pre_execution_query=pre_execution_query,
        )
    elif engine == "adbc":
        if not isinstance(query, str):
            msg = f"only a single SQL query string is accepted for adbc, got a {qualified_type_name(query)!r} type"
            raise ValueError(msg)
        if pre_execution_query:
            msg = "the 'adbc' engine does not support use of `pre_execution_query`"
            raise ValueError(msg)
        return _read_sql_adbc(
            query,
            connection_uri=uri,
            schema_overrides=schema_overrides,
            execute_options=execute_options,
        )
    else:
        msg = f"engine must be one of {{'connectorx', 'adbc'}}, got {engine!r}"
        raise ValueError(msg)

View on GitHub (pinned to df599052da)

Solutions

  1. Remove pre_execution_query when using engine='adbc'
  2. Run setup statements separately over the same database before the adbc read (note adbc opens its own connection, so prefer server-side/session-scoped settings)
  3. Use engine='connectorx' (>= 0.4.2) if you need pre_execution_query

Example fix

# before
pl.read_database_uri(q, uri, engine="adbc", pre_execution_query="SET ROLE reader")

# after
pl.read_database_uri(q, uri, engine="adbc")  # apply setup via the database/session instead
Defensive patterns

Strategy: validation

Validate before calling

if engine == "adbc" and pre_execution_query:
    pre_execution_query = None  # adbc does not support it

Prevention

When it happens

Trigger: pl.read_database_uri(query, uri, engine='adbc', pre_execution_query='SET TIME ZONE ...').

Common situations: Engine-agnostic helper functions that always pass pre_execution_query; migrating from connectorx to adbc while keeping session-setup statements.

Related errors


AI-assisted analysis of pola-rs/polars@df599052da (2026-08-16). Data as JSON: /api/errors/5015e475df8ea1b7. Report an issue: GitHub.