Skip to content

Support deep schema pruning and projection #11745

@adragomir

Description

@adragomir

Is your feature request related to a problem or challenge?

At the moment, Datafusion supports top-level column pruning - we have a mechanism, projection: [usize] where we detect, and pass through all the layers a set of top-level columns to get from a schema. The columns are inferred from the input and passed through all the layers (logical -> optimize -> physical). Some implementation can also take advantage of these to minimize the data read from storage at the lowest level .

However, for deeply nested schemas (a small number of huge deeply nested top-level column, list of structs with maps etc), this optimization is not so useful, because the actual top level columns are very large.

Describe the solution you'd like

We should have a way to represent, and push through all the layers the "deep" projection of the actual leaves that we need in the query.
The schema and data returned after applying the deep schema pruning should reflect the changes (select 1 field from a struct in a list, we should get a list with a struct with a single field etc)
The feature needs to be applicable only to physical layouts that actually support it (for example Parquet and Arrow)

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions