Skip to content

Commit

Permalink
Allow all field types for value count aggregation
Browse files Browse the repository at this point in the history
  • Loading branch information
stratoula committed Oct 5, 2020
1 parent 536e857 commit e439647
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function getSupportedFieldsByMetricType(type) {
case METRIC_TYPES.CARDINALITY:
return Object.values(KBN_FIELD_TYPES).filter((t) => t !== KBN_FIELD_TYPES.HISTOGRAM);
case METRIC_TYPES.VALUE_COUNT:
return [KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.HISTOGRAM, KBN_FIELD_TYPES.STRING];
return Object.values(KBN_FIELD_TYPES);
case METRIC_TYPES.AVERAGE:
case METRIC_TYPES.SUM:
return [KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.HISTOGRAM];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,23 @@
*/

import { getSupportedFieldsByMetricType } from './get_supported_fields_by_metric_type';
import { KBN_FIELD_TYPES } from '../../../../../../plugins/data/public';

describe('getSupportedFieldsByMetricType', () => {
const shouldHaveHistogramAndNumbers = (type) =>
it(`should return numbers and histogram for ${type}`, () => {
expect(getSupportedFieldsByMetricType(type)).toEqual(['number', 'histogram']);
});
const shouldHaveHistogramNumbersAndStrings = (type) =>
it(`should return numbers, histogram and strings for ${type}`, () => {
expect(getSupportedFieldsByMetricType(type)).toEqual(['number', 'histogram', 'string']);
const shouldSupportAllFieldTypes = (type) =>
it(`should return all field types for ${type}`, () => {
expect(getSupportedFieldsByMetricType(type)).toEqual(Object.values(KBN_FIELD_TYPES));
});
const shouldHaveOnlyNumbers = (type) =>
it(`should return only numbers for ${type}`, () => {
expect(getSupportedFieldsByMetricType(type)).toEqual(['number']);
});

shouldHaveHistogramNumbersAndStrings('value_count');
shouldSupportAllFieldTypes('value_count');
shouldHaveHistogramAndNumbers('avg');
shouldHaveHistogramAndNumbers('sum');

Expand Down

0 comments on commit e439647

Please sign in to comment.