-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Add referenced pipeline aggs to every level of query #31121
Add referenced pipeline aggs to every level of query #31121
Conversation
Pinging @elastic/kibana-app |
Would it make sense to add a functional test for this? |
💚 Build Succeeded |
unit test is perfect imo |
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.
Code LGTM, tested Chrome OSX and not seeing any issues 👍
Agreed unit test should suffice here; this is ultimately a bug in agg_configs so a functional test for table vis is probably just adding unnecessary overhead at this point.
vis.isHierarchical = _.constant(true); | ||
|
||
const topLevelDsl = vis.aggs.toDsl(vis.isHierarchical())['2']; | ||
expect(topLevelDsl.aggs).to.have.keys(['1', '1-bucket']); |
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.
nit: It might be nice to include an assertion for the correct buckets_path
as well; something like:
expect(topLevelDsl.aggs['1'].avg_bucket).to.have.property('buckets_path', '1-bucket>_count');
I realize that isn't validating the precise problem you are fixing here, but for those looking at this test in the future, it could make it clearer how everything fits together & why we need to check that the parent aggs have been added at each level.
@@ -193,6 +193,13 @@ class AggConfigs extends IndexedArray { | |||
if (subAggs && nestedMetrics) { | |||
nestedMetrics.forEach(agg => { | |||
subAggs[agg.config.id] = agg.dsl; | |||
// if a nested metric agg has parent aggs, we have to add them to every level of the tree | |||
// to make sure "bucket_path" references in the nested metric agg itself are still working |
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 comment is super helpful, thanks for adding.
💔 Build Failed |
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! thanks!
09a2a82
to
fae9520
Compare
💚 Build Succeeded |
Summary
Fixes #25974
When using sibling pipeline aggregations as metric and activating "Show metric at all levels", the resulting ES query didn't correctly add the referenced pipeline aggs to every level.
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.- [ ] This was checked for cross-browser compatibility, including a check against IE11- [ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support- [ ] Documentation was added for features that require explanation or tutorials- [ ] This was checked for keyboard-only and screenreader accessibilityFor maintainers