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

Add referenced pipeline aggs to every level of query #31121

Merged
merged 3 commits into from
Feb 21, 2019

Conversation

flash1293
Copy link
Contributor

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 strikethroughs to 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

For maintainers

@flash1293 flash1293 added Feature:Data Table Data table visualization feature release_note:fix v7.0.0 Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.0.0 v6.7.0 labels Feb 14, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app

@flash1293 flash1293 changed the title 25974/data table bucket metrics Add referenced pipeline aggs to every level of query Feb 14, 2019
@flash1293
Copy link
Contributor Author

Would it make sense to add a functional test for this?

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@ppisljar
Copy link
Member

unit test is perfect imo

Copy link
Member

@lukeelmers lukeelmers left a 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']);
Copy link
Member

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

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.

@elasticmachine
Copy link
Contributor

💔 Build Failed

Copy link
Member

@ppisljar ppisljar left a comment

Choose a reason for hiding this comment

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

LGTM! thanks!

@flash1293 flash1293 force-pushed the 25974/data-table-bucket-metrics branch from 09a2a82 to fae9520 Compare February 21, 2019 15:06
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Data Table Data table visualization feature release_note:fix Team:Visualizations Visualization editors, elastic-charts and infrastructure v6.7.0 v7.0.0 v7.2.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants