Skip to content

[C++] Support casting from storage type to extension type #30057

Description

@asfimport

We already support casting an extension array to its storage type (ARROW-7858):

>>> frompyarrow.tests.test_extension_typeimportIntegerType
>>> arr = pa.array([1, 2, 3], pa.int64())
>>> arr_ext = pa.ExtensionArray.from_storage(IntegerType(), arr)
>>> arr_ext.cast(arr.type)
Out[29]: <pyarrow.lib.Int64Arrayobjectat0x7f7b0d4739a0>
[
1,
2,
3
]

but we don't support the cast the other way around from storage type to extension type:

>>> arr.cast(arr_ext.type)
...
ArrowNotImplementedError: Unsupportedcastfromint64toextension<arrow.py_extension_type<IntegerType>> (noavailablecastfunctionfortargettype)
../src/arrow/compute/cast.cc:119GetCastFunctionInternal(cast_options->to_type, args[0].type().get())

Reporter: Joris Van den Bossche / @jorisvandenbossche
Assignee: Miles Granger / @milesgranger

Related issues:

PRs and other links:

Note: This issue was originally created as ARROW-14500. Please see the migration documentation for further details.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions