henryharbeck commented on code in PR #3556:
URL: https://github.com/apache/arrow-adbc/pull/3556#discussion_r2423372446
##########
python/adbc_driver_manager/adbc_driver_manager/_dbapi_backend.py:
##########
@@ -179,8 +179,21 @@ def import_array_stream(
) -> typing.Any:
return polars.from_arrow(handle)
- def import_schema(self, handle: _lib.ArrowSchemaHandle) -> typing.Any:
- raise _lib.NotSupportedError("Polars does not support
__arrow_c_schema__")
+ def import_schema(self, handle: _lib.ArrowSchemaHandle) ->
polars.Schema:
+ def parse_version(version: str) -> tuple[int, ...]:
+ return tuple(int(v) for v in version.split("."))
+
+ # The version that Polars added support to initialize a schema via
the
+ # __arrow_c_schema__ interface
+ required_version = "1.32.2"
+ polars_version = polars.__version__
+ if parse_version(polars_version) >=
parse_version(required_version):
+ return polars.Schema(handle)
Review Comment:
Alternatively, could leave the version check and just `return
polars.Schema(handle)` immediately.
Would raise with the below before the required version. IMO providing the
user a nicer error message is preferable.
```
Traceback (most recent call last):
File
"/home/henry/development/arrow-adbc/python/adbc_driver_manager/try_import_schema.py",
line 11, in <module>
schema = conn.adbc_get_table_schema("test_table_schema")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File
"/home/henry/development/arrow-adbc/python/adbc_driver_manager/adbc_driver_manager/dbapi.py",
line 521, in adbc_get_table_schema
return self._backend.import_schema(handle)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File
"/home/henry/development/arrow-adbc/python/adbc_driver_manager/adbc_driver_manager/_dbapi_backend.py",
line 183, in import_schema
return polars.Schema(handle)
^^^^^^^^^^^^^^^^^^^^^
File
"/home/henry/.cache/uv/archive-v0/SC8MnmcDLgKYq5uEoGc4z/lib/python3.11/site-packages/polars/schema.py",
line 102, in __init__
for name, tp in input:
TypeError: 'adbc_driver_manager._lib.ArrowSchemaHandle' object is not
iterable
```
--
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]