GitHub user michalc edited a discussion: How to insert data into a VECTOR
PostgreSQL column (from Python)?
I'm looking to insert data into a VECTOR column by using
`adbc_get_table_schema` to determine the schema of a table but having some
problems getting beyond creating a RecordBatch (which I then would use in a
RecordBatchReader and adbc_ingest)
Specifically, running:
```python
import adbc_driver_postgresql.dbapi
import pyarrow as pa
with
adbc_driver_postgresql.dbapi.connect("postgresql://postgres:[email protected]:5432/")
as conn:
with conn.cursor() as cursor:
cursor.execute('CREATE TABLE my_table (my_vector VECTOR)')
schema = conn.adbc_get_table_schema("my_table")
pa.RecordBatch.from_pylist([
{
'my_vector': [1, 2]
}
], schema=schema)
```
Results in an error:
```
File "[...]", line 8, in <module>
pa.RecordBatch.from_pylist([
File "pyarrow/table.pxi", line 2046, in pyarrow.lib._Tabular.from_pylist
File "pyarrow/table.pxi", line 6438, in pyarrow.lib._from_pylist
File "pyarrow/table.pxi", line 3546, in pyarrow.lib.RecordBatch.from_arrays
File "pyarrow/table.pxi", line 1622, in pyarrow.lib._sanitize_arrays
File "pyarrow/array.pxi", line 405, in pyarrow.lib.asarray
File "pyarrow/array.pxi", line 375, in pyarrow.lib.array
File "pyarrow/array.pxi", line 45, in pyarrow.lib._sequence_to_array
File "pyarrow/error.pxi", line 155, in
pyarrow.lib.pyarrow_internal_check_status
File "pyarrow/error.pxi", line 92, in pyarrow.lib.check_status
pyarrow.lib.ArrowTypeError: Expected bytes, got a 'list' object
```
It seems to only want `bytes` as the vector data, but I'm not sure how to
encode a list as bytes. How can I create the RecordBatch, or otherwise insert
data into a VECTOR column?
GitHub link: https://github.com/apache/arrow-adbc/discussions/2900
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]