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 1db1f1b  fix(python/adbc_driver_manager): fix 
Cursor.adbc_read_partition (#452)
1db1f1b is described below

commit 1db1f1b950a6c1f24ea9816d9e3ab4866b92302b
Author: David Li <[email protected]>
AuthorDate: Mon Feb 13 17:57:51 2023 -0500

    fix(python/adbc_driver_manager): fix Cursor.adbc_read_partition (#452)
---
 .github/workflows/native-unix.yml                  | 25 +++++++++++++++++++---
 python/adbc_driver_flightsql/tests/conftest.py     | 25 ++++++++++++++++++----
 python/adbc_driver_flightsql/tests/test_dbapi.py   | 12 +++++++++++
 .../adbc_driver_manager/_lib.pyx                   |  4 ++++
 .../adbc_driver_manager/dbapi.py                   |  2 +-
 5 files changed, 60 insertions(+), 8 deletions(-)

diff --git a/.github/workflows/native-unix.yml 
b/.github/workflows/native-unix.yml
index f6a6ef4..6d049cc 100644
--- a/.github/workflows/native-unix.yml
+++ b/.github/workflows/native-unix.yml
@@ -247,7 +247,8 @@ jobs:
         shell: bash -l {0}
         run: |
           mamba install -c conda-forge \
-            --file ci/conda_env_cpp.txt
+            --file ci/conda_env_cpp.txt \
+            --file ci/conda_env_python.txt
       - uses: actions/setup-go@v3
         with:
           go-version: 1.18.6
@@ -308,6 +309,24 @@ jobs:
         run: |
           ./ci/scripts/cpp_build.sh "$(pwd)" "$(pwd)/build"
           ./ci/scripts/cpp_test.sh "$(pwd)" "$(pwd)/build"
+      - name: Build Python Flight SQL driver
+        shell: bash -l {0}
+        env:
+          BUILD_ALL: "0"
+          BUILD_DRIVER_FLIGHTSQL: "1"
+          BUILD_DRIVER_MANAGER: "1"
+        run: |
+          ./ci/scripts/python_build.sh "$(pwd)" "$(pwd)/build"
+      - name: Test Python Flight SQL driver against Dremio
+        shell: bash -l {0}
+        env:
+          BUILD_ALL: "0"
+          BUILD_DRIVER_FLIGHTSQL: "1"
+          ADBC_DREMIO_FLIGHTSQL_URI: "grpc+tcp://localhost:32010"
+          ADBC_DREMIO_FLIGHTSQL_USER: "dremio"
+          ADBC_DREMIO_FLIGHTSQL_PASS: "dremio123"
+        run: |
+          ./ci/scripts/python_test.sh "$(pwd)" "$(pwd)/build"
       - name: Stop SQLite server
         shell: bash -l {0}
         run: |
@@ -539,11 +558,11 @@ jobs:
       - name: Build Python Driver Flight SQL
         shell: bash -l {0}
         run: |
-          env BUILD_ALL=0 BUILD_DRIVER_FLIGHTSQLGO=1 
./ci/scripts/python_build.sh "$(pwd)" "$(pwd)/build" "$HOME/local"
+          env BUILD_ALL=0 BUILD_DRIVER_FLIGHTSQL=1 
./ci/scripts/python_build.sh "$(pwd)" "$(pwd)/build" "$HOME/local"
       - name: Test Python Driver Flight SQL
         shell: bash -l {0}
         run: |
-          env BUILD_ALL=0 BUILD_DRIVER_FLIGHTSQLGO=1 
./ci/scripts/python_test.sh "$(pwd)" "$(pwd)/build" "$HOME/local"
+          env BUILD_ALL=0 BUILD_DRIVER_FLIGHTSQL=1 ./ci/scripts/python_test.sh 
"$(pwd)" "$(pwd)/build" "$HOME/local"
       - name: Build Python Driver PostgreSQL
         shell: bash -l {0}
         run: |
diff --git a/python/adbc_driver_flightsql/tests/conftest.py 
b/python/adbc_driver_flightsql/tests/conftest.py
index 649f0d8..175c226 100644
--- a/python/adbc_driver_flightsql/tests/conftest.py
+++ b/python/adbc_driver_flightsql/tests/conftest.py
@@ -26,19 +26,36 @@ import adbc_driver_manager
 
 @pytest.fixture
 def dremio_uri():
-    dremio_uri = os.environ.get("ADBC_DREMIO_TEST_URI")
+    dremio_uri = os.environ.get("ADBC_DREMIO_FLIGHTSQL_URI")
     if not dremio_uri:
-        pytest.skip("Set ADBC_DREMIO_TEST_URI to run tests")
+        pytest.skip("Set ADBC_DREMIO_FLIGHTSQL_URI to run tests")
+    yield dremio_uri
 
 
 @pytest.fixture
 def dremio(dremio_uri):
-    with adbc_driver_flightsql.connect(dremio_uri) as db:
+    username = os.environ.get("ADBC_DREMIO_FLIGHTSQL_USER")
+    password = os.environ.get("ADBC_DREMIO_FLIGHTSQL_PASS")
+    with adbc_driver_flightsql.connect(
+        dremio_uri,
+        db_kwargs={
+            "username": username,
+            "password": password,
+        },
+    ) as db:
         with adbc_driver_manager.AdbcConnection(db) as conn:
             yield conn
 
 
 @pytest.fixture
 def dremio_dbapi(dremio_uri):
-    with adbc_driver_flightsql.dbapi.connect(dremio_uri) as conn:
+    username = os.environ.get("ADBC_DREMIO_FLIGHTSQL_USER")
+    password = os.environ.get("ADBC_DREMIO_FLIGHTSQL_PASS")
+    with adbc_driver_flightsql.dbapi.connect(
+        dremio_uri,
+        db_kwargs={
+            "username": username,
+            "password": password,
+        },
+    ) as conn:
         yield conn
diff --git a/python/adbc_driver_flightsql/tests/test_dbapi.py 
b/python/adbc_driver_flightsql/tests/test_dbapi.py
index f1b0324..115cd5a 100644
--- a/python/adbc_driver_flightsql/tests/test_dbapi.py
+++ b/python/adbc_driver_flightsql/tests/test_dbapi.py
@@ -15,8 +15,20 @@
 # specific language governing permissions and limitations
 # under the License.
 
+import pyarrow
+
 
 def test_query_trivial(dremio_dbapi):
     with dremio_dbapi.cursor() as cur:
         cur.execute("SELECT 1")
         assert cur.fetchone() == (1,)
+
+
+def test_query_partitioned(dremio_dbapi):
+    with dremio_dbapi.cursor() as cur:
+        partitions, schema = cur.adbc_execute_partitions("SELECT 1")
+        assert len(partitions) == 1
+        assert schema.equals(pyarrow.schema([("EXPR$0", "int32")]))
+
+        cur.adbc_read_partition(partitions[0])
+        assert cur.fetchone() == (1,)
diff --git a/python/adbc_driver_manager/adbc_driver_manager/_lib.pyx 
b/python/adbc_driver_manager/adbc_driver_manager/_lib.pyx
index 7598b69..3b9b44a 100644
--- a/python/adbc_driver_manager/adbc_driver_manager/_lib.pyx
+++ b/python/adbc_driver_manager/adbc_driver_manager/_lib.pyx
@@ -502,6 +502,10 @@ cdef class AdbcDatabase(_AdbcHandle):
             if key == "init_func":
                 status = AdbcDriverManagerDatabaseSetInitFunc(
                     &self.database, <CAdbcDriverInitFunc> (<uintptr_t> value), 
&c_error)
+            elif key is None:
+                raise ValueError("key cannot be None")
+            elif value is None:
+                raise ValueError(f"value for key '{key}' cannot be None")
             else:
                 key = key.encode("utf-8")
                 value = value.encode("utf-8")
diff --git a/python/adbc_driver_manager/adbc_driver_manager/dbapi.py 
b/python/adbc_driver_manager/adbc_driver_manager/dbapi.py
index 2b355ac..66500be 100644
--- a/python/adbc_driver_manager/adbc_driver_manager/dbapi.py
+++ b/python/adbc_driver_manager/adbc_driver_manager/dbapi.py
@@ -766,7 +766,7 @@ class Cursor(_Closeable):
         This is an extension and not part of the DBAPI standard.
         """
         self._results = None
-        handle = self.conn._conn.read_partition(partition)
+        handle = self._conn._conn.read_partition(partition)
         self._rowcount = -1
         self._results = _RowIterator(
             pyarrow.RecordBatchReader._import_from_c(handle.address)

Reply via email to