You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "Joris Van den Bossche (JIRA)" <ji...@apache.org> on 2019/08/08 15:16:00 UTC

[jira] [Commented] (ARROW-6176) [Python] Allow to subclass ExtensionArray to attach to custom extension type

    [ https://issues.apache.org/jira/browse/ARROW-6176?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16903064#comment-16903064 ] 

Joris Van den Bossche commented on ARROW-6176:
----------------------------------------------

This might be done by adding a {{ExtenstionType.__arrow_ext_class__}} that points to the subclass? In that way {{pyarrow_wrap_array}} can use that class instead of one of the predefined ones in {{_array_classes}}.

> [Python] Allow to subclass ExtensionArray to attach to custom extension type
> ----------------------------------------------------------------------------
>
>                 Key: ARROW-6176
>                 URL: https://issues.apache.org/jira/browse/ARROW-6176
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: Python
>            Reporter: Joris Van den Bossche
>            Priority: Major
>
> Currently, you can define a custom extension type in Python with 
> {code}
> class UuidType(pa.ExtensionType):
>     def __init__(self):
>         pa.ExtensionType.__init__(self, pa.binary(16))
>     def __reduce__(self):
>         return UuidType, ()
> {code}
> but the array you can create with this is always ExtensionArray. We should provide a way to define a subclass (eg `UuidArray` in this case) that can hold custom logic.
> For example, a user might want to define `UuidArray` such that `arr[i]` returns an instance of Python's `uuid.UUID`
> From https://github.com/apache/arrow/pull/4532#pullrequestreview-249396691



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)