Skip to content

Redesign the try_reverse_output to support more cases #19403

Description

@zhuqi-lucas

Is your feature request related to a problem or challenge?

After #19064 done, i found it can't meet my internal project requirements:

  1. We can redesign the try_reverse_output to use eq_properties
  2. We will change to use ordering_satisfy because it can handle the following cases:
        // - Normalizes both orderings (removes constants)
        // - Checks monotonic functions
        // - Handles prefix matching

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

No response

Activity

  1. Nithurshen commented on Dec 22, 2025

    @Nithurshen
    Contributor

    Hi @zhuqi-lucas , I have opened a PR to address this issue.

    I implemented the logic in PushdownSort to utilize EquivalenceProperties. The optimizer now detects if a column in the sort prefix is constant and strips it from the required_ordering before attempting the pushdown.

    I've also added a unit test using a mock plan to verify that the SortExec is correctly removed when the prefix is constant.

    Kindly let me know what you think.

  2. zhuqi-lucas commented on Dec 22, 2025

    @zhuqi-lucas
    ContributorAuthor

    Hi @Nithurshen , sorry i already had a PR, and i will redesign the logic here, and it's not limited to prefix removal, but also monotonic, etc. Also i will update my slt cases.

  3. self-assigned this
    on Dec 22, 2025
  4. Nithurshen commented on Dec 22, 2025

    @Nithurshen
    Contributor

    @zhuqi-lucas, No problem.
    I will close mine.

  5. changed the title [-]Support sort prefix removal when it's logical_constants.[/-] [+]Redesign the try_reverse_output to support more cases[/+] on Dec 22, 2025
  6. added a commit that references this issue on Dec 29, 2025
    10db6b3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions