Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
findepi opened this issue Dec 13, 2024 · 0 comments
Labels
performance Make DataFusion faster

Comments

@findepi
Copy link
Member

findepi commented Dec 13, 2024

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

@findepi findepi added the performance Make DataFusion faster label Dec 13, 2024
@findepi findepi 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 Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Make DataFusion faster
Projects
None yet
Development

No branches or pull requests

1 participant