Skip to content

Feature Request: Don't require PyArrow for parameterized queries that use a Python sequence #2827

Open
@henryharbeck

Description

@henryharbeck

What feature or improvement would you like to see?

Thank you very much for the work in #2609, it is awesome!

A small follow-up request: Don't require PyArrow for parameterized queries that use a Python sequence.

By way of example

# /// script
# dependencies = [
#   "adbc-driver-postgresql==1.6.0",
#   "polars",
# ]
# ///

import adbc_driver_postgresql.dbapi

uri = "postgresql://postgres:postgres@localhost:5433"
param_q = "SELECT * FROM GENERATE_SERIES(1, 5) AS s WHERE s > $1"
plain_q = param_q.replace("$1", "3")


with (
    adbc_driver_postgresql.dbapi.connect(uri) as conn,
    conn.cursor() as cur,
):
    # Works
    cur.execute(plain_q)
    print(cur.fetch_polars())

    # Raises adbc_driver_manager.ProgrammingError: This API requires PyArrow to be installed
    cur.execute(param_q, (3,))
    print(cur.fetch_polars())

Output:

$ uv run parameterised_adbc_pg.py
shape: (2, 1)
┌─────┐
│ s   │
│ --- │
│ i32 │
╞═════╡
│ 4   │
│ 5   │
└─────┘
Traceback (most recent call last):
  File "/home/henry/development/adbc-polars-duck-bq-pg/new/parameterised_adbc_pg.py", line 24, in <module>
    cur.execute(param_q, (3,))
    ~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/home/henry/.cache/uv/environments-v2/parameterised-adbc-pg-8d3fedcf9cc86039/lib/python3.13/site-packages/adbc_driver_manager/dbapi.py", line 728, in execute
    self._prepare_execute(operation, parameters)
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/henry/.cache/uv/environments-v2/parameterised-adbc-pg-8d3fedcf9cc86039/lib/python3.13/site-packages/adbc_driver_manager/dbapi.py", line 706, in _prepare_execute
    _requires_pyarrow()
    ~~~~~~~~~~~~~~~~~^^
  File "/home/henry/.cache/uv/environments-v2/parameterised-adbc-pg-8d3fedcf9cc86039/lib/python3.13/site-packages/adbc_driver_manager/dbapi.py", line 1345, in _requires_pyarrow
    raise ProgrammingError(
    ...<2 lines>...
    )
adbc_driver_manager.ProgrammingError: This API requires PyArrow to be installed

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions