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

Fix rounding composite aggs on sorted index #57867

Merged
merged 3 commits into from
Jun 9, 2020

Conversation

jimczi
Copy link
Contributor

@jimczi jimczi commented Jun 9, 2020

This commit fixes a bug on the composite aggregation when the index
is sorted and the primary composite source needs to round values (date_histo).
In such case, we cannot take into account the subsequent sources even if they
match the index sort because the rounding of the primary sort value may break
the original index order.

Fixes #57849

This commit fixes a bug on the composite aggregation when the index
is sorted and the primary composite source needs to round values (date_histo).
In such case, we cannot take into account the subsequent sources even if they
match the index sort because the rounding of the primary sort value may break
the original index order.

Fixes elastic#57849
@elasticmachine
Copy link
Collaborator

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

@elasticmachine elasticmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Jun 9, 2020
@hendrikmuhs
Copy link

I think it would be nice to target 7.7.2 as well.

@jimczi Do you know which versions are affected in addition to 7.7?

@nik9000 nik9000 self-requested a review June 9, 2020 13:23
@@ -231,6 +235,10 @@ private Sort buildIndexSortPrefix(LeafReaderContext context) throws IOException
break;
}
sortFields.add(indexSortField);
if (sourceConfig.valuesSource() instanceof RoundingValuesSource) {
// rounded values break the index sort
Copy link
Member

Choose a reason for hiding this comment

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

It's probably worth explaining why. I think it is because the rounding "squashes" many values together so we can't get the order of the sub-values by looking at any one key. We'd have to merge all the values that round to that key and get the sub-values from that. And that isn't the kind of this this index sorting optimization does.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

++, I pushed e486057

Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

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

LGTM

@jimczi
Copy link
Contributor Author

jimczi commented Jun 9, 2020

Do you know which versions are affected in addition to 7.7?

The bug was introduced in 7.6 by #48399. I'll merge to 7.7 too.

@jimczi jimczi added the v7.7.2 label Jun 9, 2020
@jimczi jimczi merged commit e3fcda4 into elastic:master Jun 9, 2020
@jimczi jimczi deleted the bug/index_sort_composite_aggs branch June 9, 2020 18:29
jimczi added a commit that referenced this pull request Jun 9, 2020
This commit fixes a bug on the composite aggregation when the index
is sorted and the primary composite source needs to round values (date_histo).
In such case, we cannot take into account the subsequent sources even if they
match the index sort because the rounding of the primary sort value may break
the original index order.

Fixes #57849
jimczi added a commit that referenced this pull request Jun 9, 2020
This commit fixes a bug on the composite aggregation when the index
is sorted and the primary composite source needs to round values (date_histo).
In such case, we cannot take into account the subsequent sources even if they
match the index sort because the rounding of the primary sort value may break
the original index order.

Fixes #57849
jimczi added a commit that referenced this pull request Jun 9, 2020
This commit fixes a bug on the composite aggregation when the index
is sorted and the primary composite source needs to round values (date_histo).
In such case, we cannot take into account the subsequent sources even if they
match the index sort because the rounding of the primary sort value may break
the original index order.

Fixes #57849
@hendrikmuhs hendrikmuhs added v7.8.0 and removed v7.8.1 labels Jun 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/Aggregations Aggregations >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v7.7.2 v7.8.0 v7.9.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Composite Aggregation have missing buckets on paginated results with "size" and "after"
5 participants