Skip to content

MemorySourceConfig::try_swapping_with_projection discards sort information #17184

@srh

Description

@srh

Describe the bug

When pushing a projection down into a MemorySourceConfig, sorting information is discarded by try_swapping_with_projection. I forget what behavior this produces: it's either less efficient planning or perhaps some kind of sanity check failure during optimization. (But it is materially harmful.)

Prior to the refactor, MemoryExec had an equivalent form of this bug.

A PR is incoming.

To Reproduce

Construct a plan with an in-memory table, a MemorySourceConfig, that has a sort order applied to it, and a projection node on top of it, and then optimize the plan. What you'll get is, something other than a properly-optimized, properly-behaving plan with a MemorySourceConfig that has a sort order. (I forget how this bug manifests itself.)

Expected behavior

The optimized plan takes advantage of the known sort order and behaves correctly despite a projection getting pushed down into the MemorySourceConfig.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions