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

   ### What happened?
   
   `Cursor.adbc_ingest()` throws an error when an empty table is passed:
   >ProgrammingError: INVALID_ARGUMENT: [libpq] Failed to execute COPY 
statement: PGRES_FATAL_ERROR ERROR:  COPY file signature not recognized. 
SQLSTATE: 22P04
   
   Expected behaviour: creates/replaces/appends a table with 0 rows.
   
   ----------
   I am using Python:
   
   ```python
   import adbc_driver_postgresql.dbapi
   import pyarrow as pa
   ...
   ```
   
   This works:
   ```python
   n = 10
   a = pa.array(range(n), type=pa.int32())
   t = pa.Table.from_arrays([a], names=["id"])
   
   with adbc_driver_postgresql.dbapi.connect(uri=uri) as conn:
       with conn.cursor() as cursor:
           cursor.adbc_ingest(table_name="test_table", data=t, mode="replace", 
temporary=True)  # success
   ```
   
   After changing `n=10` to `n=0` to create a table with 0 rows, the same code 
fails:
   ```python
   n = 10
   a = pa.array(range(n), type=pa.int32())
   t = pa.Table.from_arrays([a], names=["id"])
   
   with adbc_driver_postgresql.dbapi.connect(uri=uri) as conn:
       with conn.cursor() as cursor:
           cursor.adbc_ingest(table_name="test_table", data=t, mode="replace", 
temporary=True)  # FAILS: ProgrammingError
   ```
   A quick check showed that we get the same error irrespectively of `mode` and 
`temporary` arguments.
   
   
   
   ### Stack Trace
   
   _No response_
   
   ### How can we reproduce the bug?
   
   _No response_
   
   ### Environment/Setup
   
   Python 3.11, installed via pip:
   ```bash
   pip list | grep adbc
   adbc-driver-manager       1.1.0
   adbc-driver-postgresql    1.1.0
   adbc-driver-sqlite        1.1.0
   ```


-- 
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