Skip to content

A problem about the projection_push_down optimizer gathers valid columns  #1312

@ic4y

Description

@ic4y

Describe the bug
why gather all columns needed for expressions in this Aggregate by using aggr_expr, rather than schema.
An error occurs when the schema is generated by a custom optimizer and does not match the column name in aggr_expr.

https://github.com/apache/arrow-datafusion/blob/0b6db52435c7c955b51e44de8a3eae58e53716d0/datafusion/src/optimizer/projection_push_down.rs#L292-L305

Nothing will go wrong like this

            schema
                .fields()[group_expr.len()..].to_vec()
                .iter()
                .enumerate()
                .try_for_each(|(i, field)| {
                    if required_columns.contains(&field.qualified_column()) {
                        new_aggr_expr.push(aggr_expr[i].clone());
                        utils::expr_to_columns(&aggr_expr[i], &mut new_required_columns)
                    } else {
                        Ok(())
                    }
                })?;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions