arrow icon indicating copy to clipboard operation
arrow copied to clipboard

[Python] BaseExtensionType doesn't extend ExtensionType

Open lidavidm opened this issue 1 year ago • 4 comments

Describe the enhancement requested

It would be nice if either (1) BaseExtensionType extended ExtensionType so that the class hierarchy makes sense, (2) there was some enum of all the type IDs that could be used for checking (I see lib.Type_FIXED_SIZE_LIST etc. but I don't think that's really meant for public use?). If we did this ideally it would be a Python enum and/or have a method to stringify the ID, too.

Component(s)

Python

lidavidm avatar Jul 16 '25 11:07 lidavidm

Hello! My name is Bogdan, I'm part of EuroPython 2025 Sprints, and this issue has piqued my interest. I want to work on it, if you don't mind :) I have following questions regarding this issue: (1): could you please elaborate on what do you exactly mean by BaseExtensionType extending the ExtensionType? Right now it is the other way around: the ExtensionType inherits from the BaseExtensionType. Do you want to switch the order? (2): do you think it would make more sense to have an enum for all types, or the type groups, e.g. TypesEnum vs SignedIntegersTypesEnum, etc.?

I want to work on the implementation of (2) in the meantime, I will open a PR with the proposed changes as soon as it's ready.

rmnskb avatar Jul 19 '25 12:07 rmnskb

Ah I see...that confused me since I would have figured BaseExtensionType was an ABC, but rather it seems BaseExtensionType is the C++ class and ExtensionType is the Python-specific subclass. That's on me for not looking closely.

I think a single enum makes the most sense. Otherwise the categorization of types can get a little arbitrary (and there are already functions in pyarrow.types to try to establish these categories)

lidavidm avatar Jul 20 '25 08:07 lidavidm

@lidavidm ok, then I will merge all existing enums that I've created into one common TypesEnum for all the types.

rmnskb avatar Jul 20 '25 10:07 rmnskb

Issue resolved by pull request 47139 https://github.com/apache/arrow/pull/47139

AlenkaF avatar Jul 25 '25 13:07 AlenkaF