You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "sjperkins (via GitHub)" <gi...@apache.org> on 2023/03/06 14:46:42 UTC

[GitHub] [arrow] sjperkins commented on a diff in pull request #34469: GH-33801: [Python] Further expose C++ Extension Types in Python

sjperkins commented on code in PR #34469:
URL: https://github.com/apache/arrow/pull/34469#discussion_r1126521520


##########
python/pyarrow/tests/test_extension_type.py:
##########
@@ -1115,9 +1115,16 @@ def test_cpp_extension_in_python(tmpdir):
     assert uuid_type.extension_name == "uuid"
     assert uuid_type.storage_type == pa.binary(16)
 
+    array_cls = uuid_type.__arrow_ext_class__()
+    scalar_cls = uuid_type.__arrow_ext_scalar_class__()
+    assert array_cls.__name__ == "ExtensionArray(uuid)"
+    assert scalar_cls.__name__ == "ExtensionScalar(uuid)"

Review Comment:
   The auto-generated class naming schema is similar to that of BaseExtensionType. i.e. `BaseExtensionType(extension<uuid>)`.



##########
python/pyarrow/tests/test_extension_type.py:
##########
@@ -1115,9 +1115,16 @@ def test_cpp_extension_in_python(tmpdir):
     assert uuid_type.extension_name == "uuid"
     assert uuid_type.storage_type == pa.binary(16)
 
+    array_cls = uuid_type.__arrow_ext_class__()
+    scalar_cls = uuid_type.__arrow_ext_scalar_class__()
+    assert array_cls.__name__ == "ExtensionArray(uuid)"
+    assert scalar_cls.__name__ == "ExtensionScalar(uuid)"
+
     array = mod._make_uuid_array()
     assert array.type == uuid_type
+    assert isinstance(array, array_cls)

Review Comment:
   prior to this change, only `isinstance(array, pyarrow.ExtensionArray)` would have held.



##########
python/pyarrow/tests/test_extension_type.py:
##########
@@ -1127,3 +1134,12 @@ def test_cpp_extension_in_python(tmpdir):
     reconstructed_array = batch.column(0)
     assert reconstructed_array.type == uuid_type
     assert reconstructed_array == array
+
+    storage = pa.array([b'0onmlkjihgfedcba']*4, pa.binary(16))
+    ext_array = pa.ExtensionArray.from_storage(uuid_type, storage)
+    assert isinstance(ext_array, array_cls)

Review Comment:
   From memory, before to this change, `pa.ExtensionArray.from_storage` would have returned a `pyarrow.ExtensionArray`.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org