Skip to content

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

Closed

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

Activity

  1. changed the title [-]Optimize ColumnarValue::into_array / ScalarValue::to_array / ScalarValue::to_array_of_size[/-] [+]Optimize `ColumnarValue::into_array` / `ScalarValue::to_array` / `ScalarValue::to_array_of_size`[/+] on Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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