cofin opened a new issue, #4567:
URL: https://github.com/apache/arrow-adbc/issues/4567

   ### What happened?
   
   `adbc_driver_postgresql` binds a canonical Arrow UUID parameter as PostgreSQL
   `bytea` instead of `uuid`.
   
   PyArrow 25.0.0 infers a Python `uuid.UUID` value as
   `extension<arrow.uuid>` with `fixed_size_binary[16]` storage. The PostgreSQL
   driver's `PostgresType::FromSchema()` recognizes `arrow.json`, but does not
   recognize `arrow.uuid`; it falls through to the storage-type switch, where 
all
   `FixedSizeBinary` values resolve to PostgreSQL `bytea`.
   
   As a result, using the parameter against a PostgreSQL `uuid` column fails 
while
   the statement is prepared:
   
   ### Stack Trace
   
   ```text
   INVALID_ARGUMENT: [libpq] Failed to prepare query: ERROR:
   operator does not exist: uuid = bytea
   HINT: No operator matches the given name and argument types.
   ```
   
   Expected behavior: a field carrying the canonical `arrow.uuid` extension name
   and valid `FixedSizeBinary(16)` storage should bind as PostgreSQL `uuid`.
   Unannotated `FixedSizeBinary(16)` should continue to bind as `bytea`.
   
   ### How can we reproduce the bug?
   
   ```python
   import os
   import uuid
   
   import pyarrow as pa
   from adbc_driver_postgresql import dbapi
   
   value = uuid.UUID("12345678-1234-5678-1234-567812345678")
   array = pa.array([value])
   
   assert str(array.type) == "extension<arrow.uuid>"
   assert str(array.storage.type) == "fixed_size_binary[16]"
   
   with dbapi.connect(os.environ["ADBC_POSTGRESQL_TEST_URI"]) as connection:
       with connection.cursor() as cursor:
           cursor.execute("CREATE TEMP TABLE adbc_uuid_repro (id uuid)")
           cursor.execute(
               """
               INSERT INTO adbc_uuid_repro
               VALUES ('12345678-1234-5678-1234-567812345678')
               """
           )
   
           # Fails because $1 is prepared as bytea.
           cursor.execute(
               "SELECT count(*) FROM adbc_uuid_repro WHERE id = $1",
               (value,),
           )
           assert cursor.fetchone()[0] == 1
   ```
   
   This reproduction uses ADBC directly; SQLSpec is not involved.
   
   Relevant source:
   
https://github.com/apache/arrow-adbc/blob/84a56fe5458beae5bf571db48de3624341bad6aa/c/driver/postgresql/postgres_type.h#L588-L638
   
   Arrow UUID specification:
   https://arrow.apache.org/docs/format/CanonicalExtensions.html#uuid
   
   ### Environment/Setup
   
   - Python 3.12
   - PostgreSQL 16
   - `adbc-driver-postgresql==1.11.0`
   - `adbc-driver-manager==1.11.0`
   - `pyarrow==25.0.0`
   - PyPI wheels
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to