voltrondata / sqlflite

An example Flight SQL Server implementation - with DuckDB and SQLite back-ends.
Apache License 2.0
209 stars 23 forks source link

conn.adbc_get_objects() resulting in error: returned inconsistent schema: #26

Closed TylerHillery closed 10 months ago

TylerHillery commented 10 months ago

I ran into an error when using the example implementation using Option 1 - Running from the published Docker Image, and connecting to the server via the ADBC Python Flight SQL Driver, I copied the python code from the README.md as well but tried calling conn.adbc_get_objects() and got the resulting error

(.venv) ➜  adbc python main.py
/home/tyler/code/sandbox/adbc/.venv/lib/python3.11/site-packages/adbc_driver_manager/dbapi.py:307: Warning: Cannot disable autocommit; conn will not be DB-API 2.0 compliant
  warnings.warn(
Traceback (most recent call last):
  File "/home/tyler/code/sandbox/adbc/main.py", line 12, in <module>
    print(conn.adbc_get_objects())
          ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tyler/code/sandbox/adbc/.venv/lib/python3.11/site-packages/adbc_driver_manager/dbapi.py", line 442, in adbc_get_objects
    handle = self._conn.get_objects(
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "adbc_driver_manager/_lib.pyx", line 772, in adbc_driver_manager._lib.AdbcConnection.get_objects
  File "adbc_driver_manager/_lib.pyx", line 232, in adbc_driver_manager._lib.check_error
adbc_driver_manager.OperationalError: UNKNOWN: [FlightSQL] endpoint 0 returned inconsistent schema: expected schema:
  fields: 1
    - catalog_name: type=utf8 but got schema:
  fields: 1
    - table_type: type=utf8 (Unknown; GetObjects(GetCatalogs))

Here is the python code

from adbc_driver_flightsql import dbapi as flight_sql, DatabaseOptions

flight_password = "flight_password" # Use an env var in production code!

with flight_sql.connect(uri="grpc+tls://localhost:31337",
                        db_kwargs={"username": "flight_username",
                                   "password": flight_password,
                                   DatabaseOptions.TLS_SKIP_VERIFY.value: "true" # Not needed if you use a trusted CA-signed TLS cert
                                   }
                        ) as conn:
   print(conn.adbc_get_objects())

I am using python version 3.11.6 on Ubuntu 22.04.3 LTS. Here are the packages I have installed in my venv

Package               Version
--------------------- -------
adbc-driver-flightsql 0.9.0
adbc-driver-manager   0.9.0
numpy                 1.26.3
pip                   23.3.2
pyarrow               15.0.0
setuptools            65.5.0

I have tried passing in various depth values into the adbc_get_objects() and different filters but they all result in the same error. I have a feeling it's because this example uses DuckDB as the backend which doesn't really have a concept of a catalog.

I am happy to help contribute to solve this (if it is indeed a real issue and not just something on my end), I would just need some initial direction as how to fix it.

TylerHillery commented 10 months ago

This issue has been resolved by the changes introduced in commit eecf5a10e8beb63436d65a0ade21082c1badfd02