Skip to content

Optimize ColumnarValue::into_array / ScalarValue::to_array / ScalarValue::to_array_of_size #13754

@findepi

Description

@findepi

When implementing functions, ColumnarValue::into_array / ScalarValue::to_array / ScalarValue::to_array_of_size are useful to reduce code complexity and denominate input arguments in terms of an array (either full-sized or 1-sized).

The code to handle scalars of structural types is

ScalarValue::List(arr) => {
Self::list_to_array_of_size(arr.as_ref() as &dyn Array, size)?
}
ScalarValue::LargeList(arr) => {
Self::list_to_array_of_size(arr.as_ref() as &dyn Array, size)?
}
ScalarValue::FixedSizeList(arr) => {
Self::list_to_array_of_size(arr.as_ref() as &dyn Array, size)?
}
ScalarValue::Struct(arr) => {
Self::list_to_array_of_size(arr.as_ref() as &dyn Array, size)?
}
ScalarValue::Map(arr) => {
Self::list_to_array_of_size(arr.as_ref() as &dyn Array, size)?

it's not optimized for the common case of input array (the scalar) being of length 1 and requested length also being 1.
In such case it could probably be reduced to Arc::clone

Metadata

Metadata

Assignees

No one assigned

    Labels

    performanceMake DataFusion faster

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions