You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by li...@apache.org on 2023/09/22 16:55:04 UTC
[arrow-adbc] branch main updated: fix(python/adbc_driver_manager): allow non-indexable sequences in executemany (#1094)
This is an automated email from the ASF dual-hosted git repository.
lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git
The following commit(s) were added to refs/heads/main by this push:
new 0d8707a5 fix(python/adbc_driver_manager): allow non-indexable sequences in executemany (#1094)
0d8707a5 is described below
commit 0d8707a5ee2622ba959b069cd173bfe6ee2aaff3
Author: William Ayd <wi...@icloud.com>
AuthorDate: Fri Sep 22 12:54:57 2023 -0400
fix(python/adbc_driver_manager): allow non-indexable sequences in executemany (#1094)
fixes https://github.com/apache/arrow-adbc/issues/1076
---
python/adbc_driver_manager/adbc_driver_manager/dbapi.py | 11 +++++------
python/adbc_driver_manager/tests/test_dbapi.py | 1 +
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/python/adbc_driver_manager/adbc_driver_manager/dbapi.py b/python/adbc_driver_manager/adbc_driver_manager/dbapi.py
index 5b563805..8edcdf4f 100644
--- a/python/adbc_driver_manager/adbc_driver_manager/dbapi.py
+++ b/python/adbc_driver_manager/adbc_driver_manager/dbapi.py
@@ -701,12 +701,11 @@ class Cursor(_Closeable):
):
arrow_parameters = seq_of_parameters
elif seq_of_parameters:
- arrow_parameters = pyarrow.record_batch(
- [
- pyarrow.array([row[col_idx] for row in seq_of_parameters])
- for col_idx in range(len(seq_of_parameters[0]))
- ],
- names=[str(i) for i in range(len(seq_of_parameters[0]))],
+ arrow_parameters = pyarrow.RecordBatch.from_pydict(
+ {
+ str(col_idx): pyarrow.array(x)
+ for col_idx, x in enumerate(map(list, zip(*seq_of_parameters)))
+ },
)
else:
arrow_parameters = pyarrow.record_batch([])
diff --git a/python/adbc_driver_manager/tests/test_dbapi.py b/python/adbc_driver_manager/tests/test_dbapi.py
index a29a661a..52b8e131 100644
--- a/python/adbc_driver_manager/tests/test_dbapi.py
+++ b/python/adbc_driver_manager/tests/test_dbapi.py
@@ -253,6 +253,7 @@ def test_execute_parameters(sqlite, parameters):
pyarrow.record_batch([[1, 3], ["a", None]], names=["float", "str"]),
pyarrow.table([[1, 3], ["a", None]], names=["float", "str"]),
pyarrow.table([[1, 3], ["a", None]], names=["float", "str"]).to_batches()[0],
+ ((x, y) for x, y in ((1, "a"), (3, None))),
],
)
def test_executemany_parameters(sqlite, parameters):