Skip to content

Simplify percentile_cont to min/max when percentile is 0 or 1 #18108

Description

@Jefffrey

Is your feature request related to a problem or challenge?

#17988 introduced percentile_cont(). If the specified percentile is 0 or 1, we could rewrite the function to use min/max instead which would be equivalent but with lower memory usage (percentile_cont() by default buffers entire input).

Describe the solution you'd like

Implement simplify() for percentile_cont, based on if fraction is a provided literal that is 0 or 1, rewriting to min/max.

Things to consider:

  • Consider sort order (percentile of 0 ascending = min, but percentile of 0 descending = max)
  • Ensure return types match
  • Does min/max have same null handling? percentile_cont ignores nulls

See this comment for reference: #17988 (comment)

Describe alternatives you've considered

If not feasible we can skip doing this.

Additional context

No response

Activity

  1. added theissue type on Oct 17, 2025
  2. petern48 commented on Oct 17, 2025

    @petern48
    Member

    I gave it a quick shot before I saw your comment. I found it a bit tricky and couldn't quite get the tests to pass for the second syntax (ran into weird schema datatype issues). I'll stop and leave it up to you. Just giving you a heads up about the tricky part. Easy thing to overlook.

  3. added a commit that references this issue on Nov 29, 2025
    73562e8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions