Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FILTER Clause for Aggregate Functions #5873

Closed
yjshen opened this issue Apr 5, 2023 · 0 comments · Fixed by #5868
Closed

FILTER Clause for Aggregate Functions #5873

yjshen opened this issue Apr 5, 2023 · 0 comments · Fixed by #5868
Labels
enhancement New feature or request

Comments

@yjshen
Copy link
Member

yjshen commented Apr 5, 2023

Is your feature request related to a problem or challenge?

Implement the FILTER clause for aggregate functions (introduced in SQL:2003). This syntax allows for filtering before aggregation.

SUM(<expression>) FILTER(WHERE <condition>)

Describe the solution you'd like

Have the filter support directly in our AggregateExec.

Describe alternatives you've considered

Rewrite the filter clause for aggregate functions to use the CASE WHEN expression during planning. However, null handling for each aggregator function regarding the filter would be error-prone.

Additional context

PostgreSQL: https://www.postgresql.org/docs/current/sql-expressions.html#SYNTAX-AGGREGATES
Spark: https://spark.apache.org/docs/3.3.2/sql-ref-syntax-qry-select-groupby.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant