Skip to content

Optimize to_char for array conversions #17152

@alamb

Description

@alamb

Is your feature request related to a problem or challenge?

Specifically the code that

The use of Vec<Option<String>> to build a string array is non ideal as it requires additional allocations for each output row along with a second copy of the data

fn to_char_array(args: &[ColumnarValue]) -> Result<ColumnarValue> {
    let arrays = ColumnarValue::values_to_arrays(args)?;
    let mut results: Vec<Option<String>> = vec![]; // <--- this is non ideal

Also, the code that falls back to date formatting calls cast for a single row every time the formatting fails -- since the failure is likely due to a date specifier that will get called for all rows, it would probably be faster to convert the entire input array to Date once the first time the specifier is retried

Describe the solution you'd like

Make to_char faster

You can evaluate your changes with the existing benchmark

cargo bench --bench to_char

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestperformanceMake DataFusion faster

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions