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

ESQL: per aggregation filtering #110821

Open
costin opened this issue Jul 12, 2024 · 3 comments
Open

ESQL: per aggregation filtering #110821

costin opened this issue Jul 12, 2024 · 3 comments
Labels
:Analytics/ES|QL AKA ESQL >enhancement >feature Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)

Comments

@costin
Copy link
Member

costin commented Jul 12, 2024

Description

Allow per-aggregation filtering:

stats ca = count(a) FILTER a > 0, cb = count(b) FILTER b > 0, c = count(), d = count(d) FILTER e > 10

P.S. There's a discussion whether to reuse WHERE or take the SQL approach and use FILTER.

@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Jul 12, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

@dgieselaar
Copy link
Member

An alternative suggestion for syntax (not sure what the cons are):

stats ca = count(FILTER a > 0), cb = count(FILTER b > 0), c = count(), d = count(FILTER e > 10)

@philippkahr
Copy link
Contributor

philippkahr commented Aug 9, 2024

Can we stick to a single term for "filtering", which is currently where? as long as where has feature parity when used inside of an aggregation?

I also prefer Darios version of writing the aggregation, as from a readability standpoint, I know where the condition is applied to and I do not need to scan for the next , to know where the filter ends.

stats ca = count(WHERE a > 0), cb = count(WHERE b > 0), c = count(), d = count(WHERE e > 10)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL >enhancement >feature Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)
Projects
None yet
Development

No branches or pull requests

4 participants