Skip to content

Calling dbapi.Coursor.description prevents use of fetch_arrow/fetch_polars methods #3543

@CaselIT

Description

@CaselIT

What happened?

If I access cursor.description before calling fetch_arrow or fetch_polars an exception is raised:

ProgrammingError: Result set has been closed or consumed

Using fetch_arrow_table or fetch_df works instead

Stack Trace

Traceback (most recent call last):
  File "source,py", line 77, in <module>
    print(cur.fetch_polars())
          ^^^^^^^^^^^^^^^^^^
  File "Lib\site-packages\adbc_driver_manager\dbapi.py", line 1211, in fetch_polars
    return self._results.fetch_polars()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "Lib\site-packages\adbc_driver_manager\dbapi.py", line 1354, in fetch_polars
    return _blocking_call(
           ^^^^^^^^^^^^^^^
  File "adbc_driver_manager/_lib.pyx", line 1770, in adbc_driver_manager._lib._blocking_call
    return func(*args, **kwargs)
  File "Lib\site-packages\adbc_driver_manager\dbapi.py", line 1357, in <lambda>
    polars.from_arrow(self.fetch_arrow()),
                      ^^^^^^^^^^^^^^^^^^
  File "Lib\site-packages\adbc_driver_manager\dbapi.py", line 1366, in fetch_arrow
    raise ProgrammingError(
adbc_driver_manager.ProgrammingError: Result set has been closed or consumed

How can we reproduce the bug?

any driver will do the same, example postgres

from adbc_driver_postgresql.dbapi import connect
url = 'postgresql://scott:tiger@localhost/test' 
c = connect(url)
with c:
    with c.cursor() as cur:
        cur.execute('select 42 as col')
        print(cur.description)  # commenting this line makes it work
        print(cur.fetch_polars())

Environment/Setup

adbc_driver_manager = 1.8.0
adbc_driver_postgresql = 1.8.0

Metadata

Metadata

Assignees

Labels

Type: bugSomething isn't working

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions