Skip to content

Conversation

@ivancea
Copy link
Contributor

@ivancea ivancea commented Jul 8, 2024

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)

ivancea added 30 commits June 20, 2024 21:29
# 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
@ivancea ivancea requested review from nik9000 and not-napoleon July 8, 2024 10:19
@github-actions
Copy link
Contributor

github-actions bot commented Jul 8, 2024

Documentation preview:

@ivancea
Copy link
Contributor Author

ivancea commented Jul 8, 2024

@elasticmachine update branch

@ivancea ivancea added Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) :Analytics/ES|QL AKA ESQL ES|QL-ui Impacts ES|QL UI >test Issues or PRs that are addressing/adding tests labels Jul 8, 2024
examples = {
@Example(file = "stats", tag = "avg"),
@Example(
description = "The expression can use inline functions. For example, to calculate the average "
Copy link
Contributor Author

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ivancea ivancea marked this pull request as ready for review July 8, 2024 11:55
@elasticsearchmachine
Copy link
Collaborator

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

@elasticsearchmachine
Copy link
Collaborator

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 "
Copy link
Member

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)
);
Copy link
Member

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));
}
Copy link
Member

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))
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@ivancea ivancea added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Jul 9, 2024
@ivancea ivancea merged commit 38cd0b3 into elastic:main Jul 9, 2024
@ivancea ivancea deleted the avg-agg-tests branch July 9, 2024 10:01
tvernum pushed a commit that referenced this pull request Feb 25, 2025
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)
tvernum pushed a commit that referenced this pull request Feb 25, 2025
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) ES|QL-ui Impacts ES|QL UI Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) >test Issues or PRs that are addressing/adding tests v8.16.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants