Skip to content

Commit

Permalink
🐛 Fix single percentile case when ES is returning no buckets (#115214)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
dej611 and kibanamachine committed Oct 19, 2021
1 parent de80e69 commit 1789a2c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ describe('AggTypeMetricSinglePercentileProvider class', () => {
).toEqual(123);
});

it('should not throw error for empty buckets', () => {
const agg = aggConfigs.getResponseAggs()[0];
expect(agg.getValue({})).toEqual(NaN);
});

it('produces the expected expression ast', () => {
const agg = aggConfigs.getResponseAggs()[0];
expect(agg.toExpressionAst()).toMatchInlineSnapshot(`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ export const getSinglePercentileMetricAgg = () => {
if (Number.isInteger(agg.params.percentile)) {
valueKey += '.0';
}
return bucket[agg.id].values[valueKey];
const { values } = bucket[agg.id] ?? {};

return values ? values[valueKey] : NaN;
},
});
};

0 comments on commit 1789a2c

Please sign in to comment.