Skip to content

Inconsistent Dyn Scalar Kernels #2837

@tustvold

Description

@tustvold

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

The _dyn_scalar comparison kernels accept a scalar value implementing num::ToPrimitive and then downcast the array, coercing the the scalar to the appropriate type. There are then further dyn_utf8_scalar and dyn_binary_scalar kernels to handle non-primitive arrays, these only handle arrays or dictionaries of arrays of the corresponding type

The _scalar_dyn arithmetic kernels are instead explicitly typed on ArrowNumericType, which is ArrowPrimitiveType with some SIMD gubbins, and accept the corresponding T::Native as a scalar argument. They then downcast to the expected PrimitiveArray or a DictionaryArray containing the corresponding PrimitiveArray

Not only is the naming inconsistent, the primitive scalar comparison kernels will perform coercion of primitive scalars, whereas the arithmetic kernels and other comparison kernels will not.

Describe the solution you'd like

I think the approach of the arithmetic kernels is the least surprising, and as an added bonus is significantly simpler to implement.

I would therefore like to propose adding new [eq | lt_eq | ...]_dyn_primitive_scalar comparison kernels, and deprecating the old [eq | lt_eq | ...]_dyn_scalar kernels, before removing them in a future release.

Describe alternatives you've considered

Additional context

The current use of ToPrimitive will likely complicate adding comparison support for decimal array (#2637) as ToPrimitive doesn't have a to_i256 method.

This may also help reduce compile times for the comparison kernels #2365 #1858

Thoughts @alamb @viirya

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