Skip to content

[C++] Casting dictionary type to use different index type #27536

@asfimport

Description

@asfimport

It's currently not implemented to cast from one dictionary type to another dictionary type to change the index type.

Small example:

In [2]: arr = pa.array(['a', 'b', 'a']).dictionary_encode()

In [3]: arr.type
Out[3]: DictionaryType(dictionary<values=string, indices=int32, ordered=0>)

In [5]: arr.cast(pa.dictionary(pa.int8(), pa.string()))
...
ArrowNotImplementedError: Unsupported cast from dictionary<values=string, indices=int32, ordered=0> to dictionary<values=string, indices=int8, ordered=0> (no available cast function for target type)
../src/arrow/compute/cast.cc:112  GetCastFunctionInternal(cast_options->to_type, args[0].type().get())

From https://stackoverflow.com/questions/66223730/how-to-change-column-datatype-with-pyarrow

Reporter: Joris Van den Bossche / @jorisvandenbossche
Assignee: Niranda Perera / @nirandaperera

Related issues:

PRs and other links:

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions