From b9621258b410513723d6bdca8a4a83675e73e74a Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Fri, 2 Oct 2020 13:50:51 +0300 Subject: [PATCH 1/3] [TSVB] Enable string fields for value count aggregation --- .../components/lib/get_supported_fields_by_metric_type.js | 1 + .../lib/get_supported_fields_by_metric_type.test.js | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/vis_type_timeseries/public/application/components/lib/get_supported_fields_by_metric_type.js b/src/plugins/vis_type_timeseries/public/application/components/lib/get_supported_fields_by_metric_type.js index c1d7aa9d40bd9..d57b722c3a73c 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/lib/get_supported_fields_by_metric_type.js +++ b/src/plugins/vis_type_timeseries/public/application/components/lib/get_supported_fields_by_metric_type.js @@ -25,6 +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]; case METRIC_TYPES.AVERAGE: case METRIC_TYPES.SUM: return [KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.HISTOGRAM]; diff --git a/src/plugins/vis_type_timeseries/public/application/components/lib/get_supported_fields_by_metric_type.test.js b/src/plugins/vis_type_timeseries/public/application/components/lib/get_supported_fields_by_metric_type.test.js index 3cd3fac191bf1..8a7e0c4b0225e 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/lib/get_supported_fields_by_metric_type.test.js +++ b/src/plugins/vis_type_timeseries/public/application/components/lib/get_supported_fields_by_metric_type.test.js @@ -24,12 +24,16 @@ describe('getSupportedFieldsByMetricType', () => { it(`should return numbers and histogram for ${type}`, () => { expect(getSupportedFieldsByMetricType(type)).toEqual(['number', 'histogram']); }); + const shouldHaveHistogramNumbersAndStrings = (type) => + it(`should return numbers and histogram for ${type}`, () => { + expect(getSupportedFieldsByMetricType(type)).toEqual(['number', 'histogram', 'string']); + }); const shouldHaveOnlyNumbers = (type) => it(`should return only numbers for ${type}`, () => { expect(getSupportedFieldsByMetricType(type)).toEqual(['number']); }); - shouldHaveHistogramAndNumbers('value_count'); + shouldHaveHistogramNumbersAndStrings('value_count'); shouldHaveHistogramAndNumbers('avg'); shouldHaveHistogramAndNumbers('sum'); From 766cf6206e51cb7a2779171224b64dcdf582008d Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Fri, 2 Oct 2020 13:52:19 +0300 Subject: [PATCH 2/3] fix test title --- .../components/lib/get_supported_fields_by_metric_type.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/vis_type_timeseries/public/application/components/lib/get_supported_fields_by_metric_type.test.js b/src/plugins/vis_type_timeseries/public/application/components/lib/get_supported_fields_by_metric_type.test.js index 8a7e0c4b0225e..ae07fee67dc38 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/lib/get_supported_fields_by_metric_type.test.js +++ b/src/plugins/vis_type_timeseries/public/application/components/lib/get_supported_fields_by_metric_type.test.js @@ -25,7 +25,7 @@ describe('getSupportedFieldsByMetricType', () => { expect(getSupportedFieldsByMetricType(type)).toEqual(['number', 'histogram']); }); const shouldHaveHistogramNumbersAndStrings = (type) => - it(`should return numbers and histogram for ${type}`, () => { + it(`should return numbers, histogram and strings for ${type}`, () => { expect(getSupportedFieldsByMetricType(type)).toEqual(['number', 'histogram', 'string']); }); const shouldHaveOnlyNumbers = (type) => From e43964751acfc9fbe605c51b258be50022aa58e3 Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Mon, 5 Oct 2020 16:59:40 +0300 Subject: [PATCH 3/3] Allow all field types for value count aggregation --- .../lib/get_supported_fields_by_metric_type.js | 2 +- .../lib/get_supported_fields_by_metric_type.test.js | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/plugins/vis_type_timeseries/public/application/components/lib/get_supported_fields_by_metric_type.js b/src/plugins/vis_type_timeseries/public/application/components/lib/get_supported_fields_by_metric_type.js index d57b722c3a73c..146e7a4bae15a 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/lib/get_supported_fields_by_metric_type.js +++ b/src/plugins/vis_type_timeseries/public/application/components/lib/get_supported_fields_by_metric_type.js @@ -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]; diff --git a/src/plugins/vis_type_timeseries/public/application/components/lib/get_supported_fields_by_metric_type.test.js b/src/plugins/vis_type_timeseries/public/application/components/lib/get_supported_fields_by_metric_type.test.js index ae07fee67dc38..4aed5348c0c18 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/lib/get_supported_fields_by_metric_type.test.js +++ b/src/plugins/vis_type_timeseries/public/application/components/lib/get_supported_fields_by_metric_type.test.js @@ -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');