-
Notifications
You must be signed in to change notification settings - Fork 25k
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: Add boolean support to Max and Min aggs #110527
ESQL: Add boolean support to Max and Min aggs #110527
Conversation
Pinging @elastic/es-analytical-engine (Team:Analytics) |
Hi @ivancea, I've created a changelog YAML for you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests are too simple and basic.
Please, add more csv tests that use more complex queries, to also cover complexities associated with plan optimizations. One example:
from employees | eval x = salary is not null | where emp_no > 10050 | stats min(salary is not null), max(x), count(*) by gender
@@ -31,6 +31,44 @@ MIN(languages):integer | |||
// end::min-result[] | |||
; | |||
|
|||
maxOfBoolean | |||
required_capability: agg_max_min_boolean_support | |||
from employees | stats s = max(still_hired); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test and from employees | stats s = min(still_hired)
can be a single one, no need to run two queries that do max
and min
separately.
The same goes for the next pair of queries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests are better, but it can be even better.
When I suggested one query, I was hoping you can come up with more queries in the same idea.
For example: from employees | eval x = salary is not null | where emp_no > 10050 | stats min_salary = min(salary is not null), max_salary = max(x), max_case = max(case(languages > 2, true, false)) by languages
which uses the case
function.
In employees.csv we have a multi-value boolean field - is_rehired
- you can use that and combine it with mv_*
functions and feed the result back to min
and max
(max(mv_min(is_rehired))
) with variations.
# Conflicts: # x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/aggregate/Max.java # x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/aggregate/Min.java
@astefan Changes made, and merged with main for new tests:
|
I regard the tests in
When adding support to functions (any type - aggregation, scalar, predicates) there should be a human reasonable amount of time spent coming up with some (not all) more complex queries that highlight the new functionality in the form of csv-spec tests. We do have a good coverage and you could take inspiration from other queries we came up with over time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@elasticmachine update branch |
@elasticmachine update branch |
set(index, value)
andfill(from, to, value)
). This way, the container is more similar to other BigArrays, and it's easier to work withPart of #110346, as Max and Min are dependencies of Top.