Skip to content

[Variant] Casting errors behavior support in variant_get #8086

@alamb

Description

@alamb

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

We introduced the basic variant_get kernel in and now we need to expand its feature set

However, it doesn't really handle the case when the variant contains a int column but the output calls for a float, for example

Describe the solution you'd like

I would like to handle this case within the variant_get kernel

Describe alternatives you've considered

I personally suggest we follow the rules in the existing arrow cast kernel, likely simply calling that kernel for shredded values, and implementing the equivalent logic for unshredded variants.

@scovich proposed https://github.com/apache/arrow-rs/pull/8021/files#r2257527874

I guess we could pursue three potential levels of casting:

Widening casts (based on type). E.g. if the type is int32, we can also handle int8, int16 and even decimal4 (if scale=0). The conversion is guaranteed to succeed losslessly.
Lossless narrowing casts (based on value). E.g. if the type is int32, we can still handle a small int64 value like 42. TBD what should happen if any one value failed to cast?
Converting casts. These are the lossy ones, e.g. converting 3.14f64 to 3i32, or 3i32 to string. I'm guessing we don't want to mess with these?

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementAny new improvement worthy of a entry in the changelog

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions