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: Expressions in aggregate functions #99828

Closed
alex-spies opened this issue Sep 22, 2023 · 3 comments · Fixed by #104387
Closed

ESQL: Expressions in aggregate functions #99828

alex-spies opened this issue Sep 22, 2023 · 3 comments · Fixed by #104387
Assignees
Labels
:Analytics/ES|QL AKA ESQL >enhancement Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)

Comments

@alex-spies
Copy link
Contributor

Description

It would be great to have support for expressions like

from employees | stats avg(languages + 1) by whatever_field

or simply

from employees | stats count(1) by whatever_field

Currently, this can be worked around using eval, e.g.:

from employees | eval langsplusone = languages+1 | stats avg(langsplusone) by whatever_field
@elasticsearchmachine elasticsearchmachine added the Team:QL (Deprecated) Meta label for query languages team label Sep 22, 2023
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-ql (Team:QL)

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/elasticsearch-esql (:Query Languages/ES|QL)

@luigidellaquila luigidellaquila self-assigned this Dec 18, 2023
@wchaparro wchaparro added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Jan 2, 2024
@elasticsearchmachine elasticsearchmachine removed the Team:QL (Deprecated) Meta label for query languages team label Jan 2, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo (Team:Analytics)

@costin costin assigned costin and unassigned luigidellaquila Jan 8, 2024
costin added a commit to costin/elasticsearch that referenced this issue Jan 16, 2024
Allow nested expressions to be used both for grouping or inside
 aggregate functions inside the stats command.
As such the grammar has been tweaked to allow the stats group to have
 optional aliasing.

Fix elastic#99828
costin added a commit to costin/elasticsearch that referenced this issue Jan 17, 2024
Allow nested expressions to be used both for grouping or inside
 aggregate functions inside the stats command.
As such the grammar has been tweaked to allow the stats group to have
 optional aliasing.

Fix elastic#99828
costin added a commit that referenced this issue Jan 17, 2024
Allow nested expressions to be used both for grouping or inside
 aggregate functions inside the stats command.
As such the grammar has been tweaked to allow the stats group to have 
 optional aliasing.
As part of this fix, preserve the original field declaration (including 
 spaces) for implicit aliases.
Improve validation for incorrect aggregate function use (as arguments,
 grouping or inside evals).

Fix #99828
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 Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants