Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polars.read_database fails on Oracle with iter_batches=True. DPY-1006: cursor is not open #16206

Closed
2 tasks done
njesp opened this issue May 14, 2024 · 4 comments · Fixed by #16380
Closed
2 tasks done
Assignees
Labels
A-io-database Area: reading/writing to databases bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars

Comments

@njesp
Copy link

njesp commented May 14, 2024

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of Polars.

Reproducible example

import oracledb
import polars as pl

sql = """
    select cast (rownum as number) id,
        cast (rownum as float) id2,
        cast ('textxxxxxx' as varchar2 (10 char)) v
    from (select rownum r
            from (select     rownum r
                        from dual
                    connect by rownum <= 1000) a,
                (select     rownum r
                        from dual
                    connect by rownum <= 1000) b,
                (select     rownum r
                        from dual
                    connect by rownum <= 1000) c
            where rownum <= 1000000000)
"""
oracledb.init_oracle_client()
con = oracledb.connect("@db")
d = pl.read_database(sql, con, iter_batches=True, batch_size=10000)
cnt = 0
for _d in d:
    cnt += _d.height
    print(cnt)
con.close()

LIne 24: for _d in d: gives this exception: oracledb.exceptions.InterfaceError: DPY-1006: cursor is not open

This is a description of the environment.

name: polars_poc
dependencies:
  - python=3.11.9
  - pip=24.0
  - pip:
    - oracledb==2.2.0
    - polars==0.20.25

Log output

No response

Issue description

This is in fact a continuation of issue 15470

Expected behavior

It should run and print a line for each 10000 rows fetched.

Installed versions

--------Version info---------
Polars:               0.20.25
Index type:           UInt32
Platform:             Windows-10-10.0.19044-SP0
Python:               3.11.9 | packaged by Anaconda, Inc. | (main, Apr 19 2024, 16:40:41) [MSC v.1916 64 bit (AMD64)]

----Optional dependencies----
adbc_driver_manager:  <not installed>
cloudpickle:          <not installed>
connectorx:           <not installed>
deltalake:            <not installed>
fastexcel:            <not installed>
fsspec:               <not installed>
gevent:               <not installed>
hvplot:               <not installed>
matplotlib:           <not installed>
nest_asyncio:         <not installed>
numpy:                <not installed>
openpyxl:             <not installed>
pandas:               <not installed>
pyarrow:              <not installed>
pydantic:             <not installed>
pyiceberg:            <not installed>
pyxlsb:               <not installed>
sqlalchemy:           <not installed>
torch:                <not installed>
xlsx2csv:             <not installed>
xlsxwriter:           <not installed>
>>>
@njesp njesp added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels May 14, 2024
@alexander-beedie alexander-beedie self-assigned this May 14, 2024
@alexander-beedie alexander-beedie added the A-io-database Area: reading/writing to databases label May 14, 2024
@alexander-beedie
Copy link
Collaborator

Hmm, I don't think the two issues are actually related, but I'll look at this tonight (I've got an Oracle docker image at home to test on) 🤔👍

@alexander-beedie
Copy link
Collaborator

alexander-beedie commented May 14, 2024

The above code works fine if you don't init the "thick" client (eg: omit the call to oracledb.init_oracle_client()). I haven't been able to set up a test env with the relevant client libraries to try in "thick" mode - endless errors so far... :-\

(Update: finally succeeded in properly registering the Oracle client libs in the Linux VM's environment, but too late to test now; will have another go tomorrow and see if I can replicate what you're seeing).

@alexander-beedie
Copy link
Collaborator

alexander-beedie commented May 22, 2024

@njesp Fix will be out shortly - look for the 0.20.28 release.
Update: out now 👌

@njesp
Copy link
Author

njesp commented May 29, 2024

@alexander-beedie Thank you. I can confirm that it now works in 0.20.28. This helps me a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-io-database Area: reading/writing to databases bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars
Projects
None yet
2 participants