pola-rs/polars · error · ValueError
the 'adbc' engine does not support use of…
Error message
the 'adbc' engine does not support use of `pre_execution_query`
What it means
read_database_uri with engine='adbc' refuses the pre_execution_query parameter because the ADBC driver API only executes a single statement per connection, so polars cannot run a secondary query before the main one. connectorx supports it; adbc does not.
Solutions
- Remove pre_execution_query and execute setup statements separately before calling read_database_uri
- Switch engine to 'connectorx' which supports pre_execution_query
- Embed the setup (e.g. schema qualification) directly into the main SQL query string
Example fix
// before
pl.read_database_uri('SELECT * FROM t', uri, engine='adbc', pre_execution_query='SET timezone=UTC')
// after
pl.read_database_uri("SET timezone=UTC; SELECT * FROM t", uri, engine='adbc') # if driver allows, or run setup via a separate connection Defensive patterns
Strategy: validation
Validate before calling
if engine == 'adbc' and pre_execution_query:
raise ValueError('pre_execution_query is not supported with engine=adbc') Try / catch
try:
df = pl.read_database_uri(q, uri, engine='adbc', pre_execution_query=setup)
except ValueError as e:
if 'pre_execution_query' in str(e):
df = pl.read_database_uri(q, uri, engine='connectorx', pre_execution_query=setup) Prevention
- Never pass pre_execution_query together with engine='adbc'
- Inline session setup into the main SQL string where the driver allows multiple statements
- Run setup statements on a separate connection before the read
When it happens
Trigger: Calling pl.read_database_uri(query, uri, engine='adbc', pre_execution_query='SET ...') with any truthy pre_execution_query string.
Common situations: Users porting connectorx-based code to adbc while keeping session-setup queries (e.g. SET timezone, USE schema) that were needed for the other engine.
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
- Cannot set `iter_batches` for
- Cannot set `iter_batches` without also setting a non-zero…
- cannot use credential_provider when passing a DeltaTable…
- engine must be one of
- `format` must be one of
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/5015e475df8ea1b7.
Report an issue: GitHub.
Appendix: source
Thrown at py-polars/src/polars/io/database/functions.py:524
"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 fe841f959e)