You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried using this extension through ADBC from Python, using the following script
import adbc_driver_flightsql.dbapi as flight_sql
with flight_sql.connect(uri="grpc://localhost:15432",
db_kwargs={"username": "avogelsgesang",
"adbc.flight.sql.rpc.call_header.x-flight-sql-database": "avogelsgesang"
}
) as conn:
with conn.cursor() as cur:
cur.execute("SELECT 42;")
x = cur.fetch_arrow_table()
print(x)
I built from source code now (based on commit 60c748a).
Unfortunately still no success.
Here is the console output which I get
avogelsgesang@avogelsges-wsl2:~/Documents$ python3 af-query.py
/home/avogelsgesang/.local/lib/python3.10/site-packages/adbc_driver_manager/dbapi.py:298: Warning: Cannot disable autocommit; conn will not be DB-API 2.0 compliant
warnings.warn(
As soon as I kill Postgres using sudo pkill -9 -u postgres, I get the following stack trace from the client
Traceback (most recent call last):
File "/home/avogelsgesang/Documents/af-query.py", line 9, in <module>
cur.execute("SELECT 42;")
File "/home/avogelsgesang/.local/lib/python3.10/site-packages/adbc_driver_manager/dbapi.py", line 669, in execute
handle, self._rowcount = self._stmt.execute_query()
File "adbc_driver_manager/_lib.pyx", line 1106, in adbc_driver_manager._lib.AdbcStatement.execute_query
File "adbc_driver_manager/_lib.pyx", line 227, in adbc_driver_manager._lib.check_error
adbc_driver_manager.OperationalError: IO: [FlightSQL] error reading from server: EOF (Unavailable; ExecuteQuery)
Are there any debug setting which I could enable so I get additional tracing on the server and/or client?
Ok, I think I am getting closer. The problem seems to be that the "parameters" of the prepared query are never set. If I use
cur.execute("SELECT $1;", parameters=(42,))
instead of
cur.execute("SELECT 42;")
everything works as expected.
For the original, non-parameterized query, I was able to confirm that parameters_ is empty when reaching PreparedStatement::select
I guess ADBC skips the call to DoPutPreparedStatementQuery in this case. Not sure if this is a client-side bug in ADBC. But even if it is, I guess the server should be robust against this and report an error?
However, error handling seems to be brittle. The query
cur.execute("SELECT 1/0;")
first hangs for a couple of minutes before then reporting
Traceback (most recent call last):
File "/home/avogelsgesang/Documents/af-query.py", line 9, in <module>
cur.execute("SELECT 1/0;")
File "/home/avogelsgesang/.local/lib/python3.10/site-packages/adbc_driver_manager/dbapi.py", line 669, in execute
handle, self._rowcount = self._stmt.execute_query()
File "adbc_driver_manager/_lib.pyx", line 1106, in adbc_driver_manager._lib.AdbcStatement.execute_query
File "adbc_driver_manager/_lib.pyx", line 227, in adbc_driver_manager._lib.check_error
adbc_driver_manager.ProgrammingError: INVALID_ARGUMENT: [FlightSQL] failed to run: Action::SelectPreparedStatement: division by zero (InvalidArgument; ExecuteQuery)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/avogelsgesang/Documents/af-query.py", line 8, in <module>
with conn.cursor() as cur:
File "/home/avogelsgesang/.local/lib/python3.10/site-packages/adbc_driver_manager/dbapi.py", line 225, in __exit__
self.close()
File "/home/avogelsgesang/.local/lib/python3.10/site-packages/adbc_driver_manager/dbapi.py", line 611, in close
self._stmt.close()
File "adbc_driver_manager/_lib.pyx", line 1078, in adbc_driver_manager._lib.AdbcStatement.close
File "adbc_driver_manager/_lib.pyx", line 1084, in adbc_driver_manager._lib.AdbcStatement.close
File "adbc_driver_manager/_lib.pyx", line 227, in adbc_driver_manager._lib.check_error
adbc_driver_manager.ProgrammingError: INVALID_ARGUMENT: [FlightSQL] stolen session: 1283150246607583965 (InvalidArgument; ClosePreparedStatement)
Exception ignored in: <function Cursor.__del__ at 0x7fa517960280>
Traceback (most recent call last):
File "/home/avogelsgesang/.local/lib/python3.10/site-packages/adbc_driver_manager/dbapi.py", line 766, in __del__
File "/home/avogelsgesang/.local/lib/python3.10/site-packages/adbc_driver_manager/dbapi.py", line 611, in close
File "adbc_driver_manager/_lib.pyx", line 1077, in adbc_driver_manager._lib.AdbcStatement.close
File "adbc_driver_manager/_lib.pyx", line 293, in adbc_driver_manager._lib._AdbcHandle._close_child
File "adbc_driver_manager/_lib.pyx", line 295, in adbc_driver_manager._lib._AdbcHandle._close_child
RuntimeError: Underflow in closing this AdbcStatement
Activity
kou commentedon Dec 8, 2023
Thanks for trying this project!
Did you try it with 0.1.0?
If so, could you try the main branch instead? There are many improvements after 0.1.0.
(We should release a new version...)
vogelsgesang commentedon Dec 8, 2023
I tried version 0.1.0, following the instructions from https://arrow.apache.org/flight-sql-postgresql/0.1.0/install.html
vogelsgesang commentedon Dec 8, 2023
I built from source code now (based on commit 60c748a).
Unfortunately still no success.
Here is the console output which I get
As soon as I kill Postgres using
sudo pkill -9 -u postgres, I get the following stack trace from the clientAre there any debug setting which I could enable so I get additional tracing on the server and/or client?
[-]Submitting a query through Python ADBC hangs forever[/-][+]Querying through Python ADBC hangs forever[/+]kou commentedon Dec 8, 2023
log_min_messages=debug5PostgreSQL configuration helps us but it generates many outputs...I'll try this later.
FYI: We have a simple ADBC client written in Ruby https://github.com/apache/arrow-flight-sql-postgresql/blob/main/benchmark/select-adbc-flight-sql.rb and it worked when I used. So ADBC client must work.
vogelsgesang commentedon Dec 8, 2023
Here is the debug output under
log_min_messages=debug5Log file contents
The query from ADBC was sent at 23:04:29 in the log file
vogelsgesang commentedon Dec 9, 2023
Ok, I think I am getting closer. The problem seems to be that the "parameters" of the prepared query are never set. If I use
instead of
everything works as expected.
For the original, non-parameterized query, I was able to confirm that
parameters_is empty when reachingPreparedStatement::selectI guess ADBC skips the call to
DoPutPreparedStatementQueryin this case. Not sure if this is a client-side bug in ADBC. But even if it is, I guess the server should be robust against this and report an error?Add support for prepared statement SELECT without parameters
kou commentedon Dec 9, 2023
Ah, good catch!
I didn't care about the case. I've fixed it: GH-179
I've opened #180 for a timeout case.
vogelsgesang commentedon Dec 9, 2023
Thanks for the patch! With this, the line
now works as expected.
However, error handling seems to be brittle. The query
first hangs for a couple of minutes before then reporting
kou commentedon Dec 9, 2023
Thanks for finding one more edge case.
Could you open a new issue for it to close this by #179?
Add support for prepared statement SELECT without parameters (#179)
Add support for prepared statement SELECT without parameters (apache#179