lidavidm commented on code in PR #1346:
URL: https://github.com/apache/arrow-adbc/pull/1346#discussion_r1420938676


##########
python/adbc_driver_manager/adbc_driver_manager/_lib.pyx:
##########
@@ -1006,26 +1088,31 @@ cdef class AdbcStatement(_AdbcHandle):
 
         Parameters
         ----------
-        data : int or ArrowArrayHandle
-        schema : int or ArrowSchemaHandle
+        data : PyCapsule or int or ArrowArrayHandle
+        schema : PyCapsule or int or ArrowSchemaHandle
         """
         cdef CAdbcError c_error = empty_error()
         cdef CArrowArray* c_array
         cdef CArrowSchema* c_schema
 
-        if isinstance(data, ArrowArrayHandle):
+        if PyCapsule_CheckExact(data):

Review Comment:
   Would it make sense to look for and call the dunder method to convert to a 
PyCapsule? 



##########
python/adbc_driver_manager/pyproject.toml:
##########
@@ -25,8 +25,8 @@ requires-python = ">=3.9"
 dynamic = ["version"]
 
 [project.optional-dependencies]
-dbapi = ["pandas", "pyarrow>=8.0.0"]
-test = ["duckdb", "pandas", "pyarrow>=8.0.0", "pytest"]
+dbapi = ["pandas", "pyarrow>=14.0.1"]

Review Comment:
   I figured we should bump it just because our official guidance is to upgrade.



##########
python/adbc_driver_manager/adbc_driver_manager/_lib.pyx:
##########
@@ -316,23 +348,56 @@ cdef class ArrowSchemaHandle:
         """The address of the ArrowSchema."""
         return <uintptr_t> &self.schema
 
+    def __arrow_c_schema__(self) -> object:
+        """Consume this object to get a PyCapsule."""
+        # Reference:
+        # 
https://arrow.apache.org/docs/dev/format/CDataInterface/PyCapsuleInterface.html#create-a-pycapsule
+        cdef CArrowSchema* allocated = <CArrowSchema*> 
malloc(sizeof(CArrowSchema))
+        allocated.release = NULL
+        capsule = PyCapsule_New(
+            <void*>allocated, "arrow_schema", &pycapsule_schema_deleter,
+        )
+        memcpy(allocated, &self.schema, sizeof(CArrowSchema))
+        self.schema.release = NULL
+        return capsule

Review Comment:
   I think moving makes sense here.



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