-
Notifications
You must be signed in to change notification settings - Fork 25.8k
ESQL: AVG aggregation tests and ignore complex surrogates #110579
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
Conversation
…se-tests-random-cases
# Conflicts: # x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/TypeResolutions.java # x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/aggregate/TopList.java # x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractAggregationTestCase.java # x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/AbstractFunctionTestCase.java # x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/FunctionName.java # x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/TopListTests.java
# Conflicts: # x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/aggregate/TopTests.java
…-tests # Conflicts: # docs/reference/esql/functions/aggregation-functions.asciidoc
|
Documentation preview: |
|
@elasticmachine update branch |
| examples = { | ||
| @Example(file = "stats", tag = "avg"), | ||
| @Example( | ||
| description = "The expression can use inline functions. For example, to calculate the average " |
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.
Added the existing examples here
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.
👍
|
Pinging @elastic/es-analytical-engine (Team:Analytics) |
|
Pinging @elastic/kibana-esql (ES|QL-ui) |
| examples = { | ||
| @Example(file = "stats", tag = "avg"), | ||
| @Example( | ||
| description = "The expression can use inline functions. For example, to calculate the average " |
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.
👍
| expression.children() | ||
| .stream() | ||
| .allMatch(child -> child instanceof FieldAttribute || child instanceof DeepCopy || child instanceof Literal) | ||
| ); |
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.
I think this is the right thing to do for now because it doesn't block the rest of the aggs. It's really a shame most of the tests for AVG don't pick up, but that's life sometimes. We'll get there.
| MultiRowTestCaseSupplier.doubleCases(1, 1000, -Double.MAX_VALUE, Double.MAX_VALUE, true) | ||
| ).flatMap(List::stream).toList()) { | ||
| suppliers.add(AvgTests.makeSupplier(fieldCaseSupplier)); | ||
| } |
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 is probably clearer as either a fully functional thing with, like .collect(supplier -> suppliers.add(AvgTests.makeSupplier(supplier)). Or fully for loopy without flatMap.
| case INTEGER -> fieldTypedData.multiRowData() | ||
| .stream() | ||
| .map(v -> (Integer) v) | ||
| .collect(Collectors.summarizingInt(Integer::intValue)) |
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.
I've found that sometimes we don't line up with these fancy methods in Collectors. So long as we do that's all good.
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.
As this works with doubles, I guess the worst that could happen is we comparing doubles with an error margin (Which I think was commented already somewhere?). If some test fails because of that, we can use it as an example and do it
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.
👍
Some work around aggregation tests, with AVG as an example: - Added tests and autogenerated docs for AVG - As AVG uses "complex" surrogates (A combination of functions), we can't trivially execute them without a complete plan. As I'm not sure it's worth it for most aggregations, I'm skipping those cases for now, as to avoid blocking other aggs tests. The bad side effect of skipping those tests is that most tests in AvgTests are actually ignored (74 of 100)
Some work around aggregation tests, with AVG as an example: - Added tests and autogenerated docs for AVG - As AVG uses "complex" surrogates (A combination of functions), we can't trivially execute them without a complete plan. As I'm not sure it's worth it for most aggregations, I'm skipping those cases for now, as to avoid blocking other aggs tests. The bad side effect of skipping those tests is that most tests in AvgTests are actually ignored (74 of 100)
Some work around aggregation tests, with AVG as an example:
The bad side effect of skipping those tests is that most tests in AvgTests are actually ignored (74 of 100)