From 95f0a450720d86cb20888e7bed4d70012ffc1576 Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Thu, 26 May 2022 10:56:02 +0300 Subject: [PATCH] Change the implementation to use singleRercentileRank agg config --- .../data/common/search/aggs/agg_types.ts | 2 + .../single_percentile_rank.test.ts.snap | 17 ++ .../data/common/search/aggs/metrics/index.ts | 2 + .../search/aggs/metrics/metric_agg_types.ts | 1 + .../search/aggs/metrics/percentile_ranks.ts | 6 - .../metrics/percentiles_get_value.test.ts | 26 --- .../aggs/metrics/percentiles_get_value.ts | 10 +- .../metrics/single_percentile_rank.test.ts | 150 ++++++++++++++++++ .../aggs/metrics/single_percentile_rank.ts | 70 ++++++++ .../aggs/metrics/single_percentile_rank_fn.ts | 101 ++++++++++++ src/plugins/data/common/search/aggs/types.ts | 4 + .../vis_types/gauge/public/vis_type/gauge.tsx | 1 + .../vis_types/gauge/public/vis_type/goal.tsx | 1 + .../heatmap/public/vis_type/heatmap.tsx | 1 + .../metric/public/metric_vis_type.ts | 1 + .../vis_types/table/public/table_vis_type.ts | 8 +- .../tagcloud/public/tag_cloud_type.ts | 1 + .../public/trigger_action/get_series.test.ts | 8 +- .../public/trigger_action/get_series.ts | 2 +- .../trigger_action/metrics_helpers.test.ts | 8 +- .../public/trigger_action/metrics_helpers.ts | 12 +- .../trigger_action/supported_metrics.ts | 2 +- .../vis_types/xy/public/vis_types/area.ts | 8 +- .../xy/public/vis_types/histogram.ts | 8 +- .../xy/public/vis_types/horizontal_bar.ts | 8 +- .../vis_types/xy/public/vis_types/line.ts | 8 +- .../dimension_panel/dimension_panel.test.tsx | 2 +- .../operations/definitions/column_types.ts | 6 - .../definitions/formula/math_examples.md | 2 +- .../definitions/percentile_ranks.test.tsx | 11 +- .../definitions/percentile_ranks.tsx | 35 ++-- .../operations/definitions/terms/index.tsx | 33 ++-- .../definitions/terms/terms.test.tsx | 36 ----- .../operations/operations.test.ts | 24 +-- .../indexpattern_datasource/to_expression.ts | 20 +-- x-pack/plugins/lens/public/types.ts | 1 - 36 files changed, 445 insertions(+), 191 deletions(-) create mode 100644 src/plugins/data/common/search/aggs/metrics/__snapshots__/single_percentile_rank.test.ts.snap create mode 100644 src/plugins/data/common/search/aggs/metrics/single_percentile_rank.test.ts create mode 100644 src/plugins/data/common/search/aggs/metrics/single_percentile_rank.ts create mode 100644 src/plugins/data/common/search/aggs/metrics/single_percentile_rank_fn.ts diff --git a/src/plugins/data/common/search/aggs/agg_types.ts b/src/plugins/data/common/search/aggs/agg_types.ts index 2e65152314cf7..0cbc3664a8659 100644 --- a/src/plugins/data/common/search/aggs/agg_types.ts +++ b/src/plugins/data/common/search/aggs/agg_types.ts @@ -29,6 +29,7 @@ export const getAggTypes = () => ({ { name: METRIC_TYPES.SUM, fn: metrics.getSumMetricAgg }, { name: METRIC_TYPES.MEDIAN, fn: metrics.getMedianMetricAgg }, { name: METRIC_TYPES.SINGLE_PERCENTILE, fn: metrics.getSinglePercentileMetricAgg }, + { name: METRIC_TYPES.SINGLE_PERCENTILE_RANK, fn: metrics.getSinglePercentileRankMetricAgg }, { name: METRIC_TYPES.MIN, fn: metrics.getMinMetricAgg }, { name: METRIC_TYPES.MAX, fn: metrics.getMaxMetricAgg }, { name: METRIC_TYPES.STD_DEV, fn: metrics.getStdDeviationMetricAgg }, @@ -102,6 +103,7 @@ export const getAggTypesFunctions = () => [ metrics.aggMax, metrics.aggMedian, metrics.aggSinglePercentile, + metrics.aggSinglePercentileRank, metrics.aggMin, metrics.aggMovingAvg, metrics.aggPercentileRanks, diff --git a/src/plugins/data/common/search/aggs/metrics/__snapshots__/single_percentile_rank.test.ts.snap b/src/plugins/data/common/search/aggs/metrics/__snapshots__/single_percentile_rank.test.ts.snap new file mode 100644 index 0000000000000..7298060839250 --- /dev/null +++ b/src/plugins/data/common/search/aggs/metrics/__snapshots__/single_percentile_rank.test.ts.snap @@ -0,0 +1,17 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AggTypeMetricSinglePercentileRankProvider class supports scripted fields 1`] = ` +Object { + "single_percentile_rank": Object { + "percentile_ranks": Object { + "script": Object { + "lang": undefined, + "source": "return 456", + }, + "values": Array [ + 1024, + ], + }, + }, +} +`; diff --git a/src/plugins/data/common/search/aggs/metrics/index.ts b/src/plugins/data/common/search/aggs/metrics/index.ts index 4d80e36325100..55af141b8fcb7 100644 --- a/src/plugins/data/common/search/aggs/metrics/index.ts +++ b/src/plugins/data/common/search/aggs/metrics/index.ts @@ -48,6 +48,8 @@ export * from './percentile_ranks_fn'; export * from './percentile_ranks'; export * from './percentiles_fn'; export * from './percentiles'; +export * from './single_percentile_rank_fn'; +export * from './single_percentile_rank'; export * from './serial_diff_fn'; export * from './serial_diff'; export * from './std_deviation_fn'; diff --git a/src/plugins/data/common/search/aggs/metrics/metric_agg_types.ts b/src/plugins/data/common/search/aggs/metrics/metric_agg_types.ts index eed6d0a378fc2..4174808892a16 100644 --- a/src/plugins/data/common/search/aggs/metrics/metric_agg_types.ts +++ b/src/plugins/data/common/search/aggs/metrics/metric_agg_types.ts @@ -21,6 +21,7 @@ export enum METRIC_TYPES { GEO_CENTROID = 'geo_centroid', MEDIAN = 'median', SINGLE_PERCENTILE = 'single_percentile', + SINGLE_PERCENTILE_RANK = 'single_percentile_rank', MIN = 'min', MAX = 'max', MOVING_FN = 'moving_avg', diff --git a/src/plugins/data/common/search/aggs/metrics/percentile_ranks.ts b/src/plugins/data/common/search/aggs/metrics/percentile_ranks.ts index 353522d51e990..3d93a368c6597 100644 --- a/src/plugins/data/common/search/aggs/metrics/percentile_ranks.ts +++ b/src/plugins/data/common/search/aggs/metrics/percentile_ranks.ts @@ -95,11 +95,5 @@ export const getPercentileRanksMetricAgg = ({ getValue(agg, bucket) { return getPercentileValue(agg, bucket) / 100; }, - getValueBucketPath(aggConfig) { - if (aggConfig.key) { - return `${aggConfig.id}`; - } - return `${aggConfig.id}.${aggConfig.params.values[0]}`; - }, }); }; diff --git a/src/plugins/data/common/search/aggs/metrics/percentiles_get_value.test.ts b/src/plugins/data/common/search/aggs/metrics/percentiles_get_value.test.ts index 073916109d0b3..06fdb8f0133ea 100644 --- a/src/plugins/data/common/search/aggs/metrics/percentiles_get_value.test.ts +++ b/src/plugins/data/common/search/aggs/metrics/percentiles_get_value.test.ts @@ -29,30 +29,4 @@ describe('getPercentileValue', () => { const value = getPercentileValue(agg, bucket); expect(value).toEqual(24.21909648206358); }); - - test('should return the correct value for an TAggConfig', () => { - const agg = { - id: '0-metric', - enabled: true, - type: 'percentile_ranks', - params: { - field: 'AvgTicketPrice', - values: [400], - }, - schema: 'metric', - } as unknown as IResponseAggConfig; - const bucket = { - doc_count: 290, - '0-metric': { - values: [ - { - key: 400, - value: 25.84782692356769, - }, - ], - }, - }; - const value = getPercentileValue(agg, bucket); - expect(value).toEqual(25.84782692356769); - }); }); diff --git a/src/plugins/data/common/search/aggs/metrics/percentiles_get_value.ts b/src/plugins/data/common/search/aggs/metrics/percentiles_get_value.ts index 938613ff7cfc9..242a12da35128 100644 --- a/src/plugins/data/common/search/aggs/metrics/percentiles_get_value.ts +++ b/src/plugins/data/common/search/aggs/metrics/percentiles_get_value.ts @@ -13,15 +13,9 @@ export const getPercentileValue = ( agg: TAggConfig, bucket: any ) => { - const { values } = bucket[agg.parentId ?? agg.id] ?? {}; + const { values } = bucket[agg.parentId] ?? {}; - const percentile: any = find(values, ({ key }) => { - if (agg.key) { - return key === agg.key; - } - - return key === agg.params.values[0]; - }); + const percentile: any = find(values, ({ key }) => key === agg.key); return percentile ? percentile.value : NaN; }; diff --git a/src/plugins/data/common/search/aggs/metrics/single_percentile_rank.test.ts b/src/plugins/data/common/search/aggs/metrics/single_percentile_rank.test.ts new file mode 100644 index 0000000000000..8017606378e42 --- /dev/null +++ b/src/plugins/data/common/search/aggs/metrics/single_percentile_rank.test.ts @@ -0,0 +1,150 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { AggConfigs, IAggConfigs } from '../agg_configs'; +import { mockAggTypesRegistry } from '../test_helpers'; +import { METRIC_TYPES } from './metric_agg_types'; + +describe('AggTypeMetricSinglePercentileRankProvider class', () => { + let aggConfigs: IAggConfigs; + + beforeEach(() => { + const typesRegistry = mockAggTypesRegistry(); + const field = { + name: 'bytes', + }; + const indexPattern = { + id: '1234', + title: 'logstash-*', + fields: { + getByName: () => field, + filter: () => [field], + }, + } as any; + + aggConfigs = new AggConfigs( + indexPattern, + [ + { + id: METRIC_TYPES.SINGLE_PERCENTILE_RANK, + type: METRIC_TYPES.SINGLE_PERCENTILE_RANK, + schema: 'metric', + params: { + field: 'bytes', + value: 1024, + }, + }, + ], + { + typesRegistry, + } + ); + }); + + it('requests the percentile ranks aggregation in the Elasticsearch query DSL', () => { + const dsl: Record = aggConfigs.toDsl(); + + expect(dsl.single_percentile_rank.percentile_ranks.field).toEqual('bytes'); + expect(dsl.single_percentile_rank.percentile_ranks.values).toEqual([1024]); + }); + + it('points to right value within multi metric for value bucket path', () => { + expect(aggConfigs.byId(METRIC_TYPES.SINGLE_PERCENTILE_RANK)!.getValueBucketPath()).toEqual( + `${METRIC_TYPES.SINGLE_PERCENTILE_RANK}.1024` + ); + }); + + it('converts the response', () => { + const agg = aggConfigs.getResponseAggs()[0]; + + expect( + agg.getValue({ + [agg.id]: { + values: { + '1024.0': 123, + }, + }, + }) + ).toEqual(1.23); + }); + + 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(` + Object { + "chain": Array [ + Object { + "arguments": Object { + "enabled": Array [ + true, + ], + "field": Array [ + "bytes", + ], + "id": Array [ + "single_percentile_rank", + ], + "schema": Array [ + "metric", + ], + "value": Array [ + 1024, + ], + }, + "function": "aggSinglePercentileRank", + "type": "function", + }, + ], + "type": "expression", + } + `); + }); + + it('supports scripted fields', () => { + const typesRegistry = mockAggTypesRegistry(); + const field = { + name: 'bytes', + scripted: true, + language: 'painless', + script: 'return 456', + }; + const indexPattern = { + id: '1234', + title: 'logstash-*', + fields: { + getByName: () => field, + filter: () => [field], + }, + } as any; + + aggConfigs = new AggConfigs( + indexPattern, + [ + { + id: METRIC_TYPES.SINGLE_PERCENTILE_RANK, + type: METRIC_TYPES.SINGLE_PERCENTILE_RANK, + schema: 'metric', + params: { + field: 'bytes', + value: 1024, + }, + }, + ], + { + typesRegistry, + } + ); + + expect(aggConfigs.toDsl()).toMatchSnapshot(); + }); +}); diff --git a/src/plugins/data/common/search/aggs/metrics/single_percentile_rank.ts b/src/plugins/data/common/search/aggs/metrics/single_percentile_rank.ts new file mode 100644 index 0000000000000..a5cb3d787341f --- /dev/null +++ b/src/plugins/data/common/search/aggs/metrics/single_percentile_rank.ts @@ -0,0 +1,70 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { i18n } from '@kbn/i18n'; +import { aggSinglePercentileRankFnName } from './single_percentile_rank_fn'; +import { MetricAggType } from './metric_agg_type'; +import { METRIC_TYPES } from './metric_agg_types'; +import type { IResponseAggConfig } from './lib/get_response_agg_config_class'; +import { KBN_FIELD_TYPES } from '../../..'; +import { BaseAggParams } from '../types'; + +const singlePercentileTitle = i18n.translate('data.search.aggs.metrics.singlePercentileRankTitle', { + defaultMessage: 'Percentile rank', +}); + +export interface AggParamsSinglePercentileRank extends BaseAggParams { + field: string; + value: number; +} + +export const getSinglePercentileRankMetricAgg = () => { + return new MetricAggType({ + name: METRIC_TYPES.SINGLE_PERCENTILE_RANK, + expressionName: aggSinglePercentileRankFnName, + dslName: 'percentile_ranks', + title: singlePercentileTitle, + valueType: 'number', + makeLabel(aggConfig) { + return i18n.translate('data.search.aggs.metrics.singlePercentileRankLabel', { + defaultMessage: 'Percentile rank of {field}', + values: { field: aggConfig.getFieldDisplayName() }, + }); + }, + getValueBucketPath(aggConfig) { + return `${aggConfig.id}.${aggConfig.params.value}`; + }, + getSerializedFormat(agg) { + return { + id: 'percent', + }; + }, + params: [ + { + name: 'field', + type: 'field', + filterFieldTypes: [KBN_FIELD_TYPES.NUMBER, KBN_FIELD_TYPES.HISTOGRAM], + }, + { + name: 'value', + default: 0, + write: (agg, output) => { + output.params.values = [agg.params.value]; + }, + }, + ], + getValue(agg, bucket) { + let valueKey = String(agg.params.value); + if (Number.isInteger(agg.params.value)) { + valueKey += '.0'; + } + const { values } = bucket[agg.id] ?? {}; + return values ? values[valueKey] / 100 : NaN; + }, + }); +}; diff --git a/src/plugins/data/common/search/aggs/metrics/single_percentile_rank_fn.ts b/src/plugins/data/common/search/aggs/metrics/single_percentile_rank_fn.ts new file mode 100644 index 0000000000000..92c88a8bcd909 --- /dev/null +++ b/src/plugins/data/common/search/aggs/metrics/single_percentile_rank_fn.ts @@ -0,0 +1,101 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { i18n } from '@kbn/i18n'; +import { ExpressionFunctionDefinition } from '@kbn/expressions-plugin/common'; +import { AggExpressionType, AggExpressionFunctionArgs, METRIC_TYPES } from '..'; + +export const aggSinglePercentileRankFnName = 'aggSinglePercentileRank'; + +type Input = any; +type AggArgs = AggExpressionFunctionArgs; +type Output = AggExpressionType; +type FunctionDefinition = ExpressionFunctionDefinition< + typeof aggSinglePercentileRankFnName, + Input, + AggArgs, + Output +>; + +export const aggSinglePercentileRank = (): FunctionDefinition => ({ + name: aggSinglePercentileRankFnName, + help: i18n.translate('data.search.aggs.function.metrics.singlePercentileRank.help', { + defaultMessage: 'Generates a serialized agg config for a single percentile rank agg', + }), + type: 'agg_type', + args: { + id: { + types: ['string'], + help: i18n.translate('data.search.aggs.metrics.singlePercentileRank.id.help', { + defaultMessage: 'ID for this aggregation', + }), + }, + enabled: { + types: ['boolean'], + default: true, + help: i18n.translate('data.search.aggs.metrics.singlePercentileRank.enabled.help', { + defaultMessage: 'Specifies whether this aggregation should be enabled', + }), + }, + schema: { + types: ['string'], + help: i18n.translate('data.search.aggs.metrics.singlePercentileRank.schema.help', { + defaultMessage: 'Schema to use for this aggregation', + }), + }, + field: { + types: ['string'], + required: true, + help: i18n.translate('data.search.aggs.metrics.singlePercentileRank.field.help', { + defaultMessage: 'Field to use for this aggregation', + }), + }, + value: { + types: ['number'], + required: true, + help: i18n.translate('data.search.aggs.metrics.singlePercentileRank.value.help', { + defaultMessage: 'Percentile rank value to fetch', + }), + }, + json: { + types: ['string'], + help: i18n.translate('data.search.aggs.metrics.singlePercentileRank.json.help', { + defaultMessage: 'Advanced json to include when the agg is sent to Elasticsearch', + }), + }, + customLabel: { + types: ['string'], + help: i18n.translate('data.search.aggs.metrics.singlePercentileRank.customLabel.help', { + defaultMessage: 'Represents a custom label for this aggregation', + }), + }, + timeShift: { + types: ['string'], + help: i18n.translate('data.search.aggs.metrics.timeShift.help', { + defaultMessage: + 'Shift the time range for the metric by a set time, for example 1h or 7d. "previous" will use the closest time range from the date histogram or time range filter.', + }), + }, + }, + fn: (input, args) => { + const { id, enabled, schema, ...rest } = args; + + return { + type: 'agg_type', + value: { + id, + enabled, + schema, + type: METRIC_TYPES.SINGLE_PERCENTILE_RANK, + params: { + ...rest, + }, + }, + }; + }, +}); diff --git a/src/plugins/data/common/search/aggs/types.ts b/src/plugins/data/common/search/aggs/types.ts index 0d5a51eaef151..942bdc492f6f7 100644 --- a/src/plugins/data/common/search/aggs/types.ts +++ b/src/plugins/data/common/search/aggs/types.ts @@ -56,6 +56,7 @@ import { AggParamsMax, AggParamsMedian, AggParamsSinglePercentile, + AggParamsSinglePercentileRank, AggParamsMin, AggParamsMovingAvg, AggParamsPercentileRanks, @@ -89,6 +90,7 @@ import { METRIC_TYPES, aggFilteredMetric, aggSinglePercentile, + aggSinglePercentileRank, } from '.'; import { AggParamsSampler } from './buckets/sampler'; import { AggParamsDiversifiedSampler } from './buckets/diversified_sampler'; @@ -175,6 +177,7 @@ export interface AggParamsMapping { [METRIC_TYPES.MAX]: AggParamsMax; [METRIC_TYPES.MEDIAN]: AggParamsMedian; [METRIC_TYPES.SINGLE_PERCENTILE]: AggParamsSinglePercentile; + [METRIC_TYPES.SINGLE_PERCENTILE_RANK]: AggParamsSinglePercentileRank; [METRIC_TYPES.MIN]: AggParamsMin; [METRIC_TYPES.STD_DEV]: AggParamsStdDeviation; [METRIC_TYPES.SUM]: AggParamsSum; @@ -225,6 +228,7 @@ export interface AggFunctionsMapping { aggMax: ReturnType; aggMedian: ReturnType; aggSinglePercentile: ReturnType; + aggSinglePercentileRank: ReturnType; aggMin: ReturnType; aggMovingAvg: ReturnType; aggPercentileRanks: ReturnType; diff --git a/src/plugins/vis_types/gauge/public/vis_type/gauge.tsx b/src/plugins/vis_types/gauge/public/vis_type/gauge.tsx index 214a71616f427..3de528bfe5e6c 100644 --- a/src/plugins/vis_types/gauge/public/vis_type/gauge.tsx +++ b/src/plugins/vis_types/gauge/public/vis_type/gauge.tsx @@ -98,6 +98,7 @@ export const getGaugeVisTypeDefinition = ( '!geo_bounds', '!filtered_metric', '!single_percentile', + '!single_percentile_rank', ], defaults: [{ schema: 'metric', type: 'count' }], }, diff --git a/src/plugins/vis_types/gauge/public/vis_type/goal.tsx b/src/plugins/vis_types/gauge/public/vis_type/goal.tsx index 0d356a5f2c721..c953cd3e5dfe2 100644 --- a/src/plugins/vis_types/gauge/public/vis_type/goal.tsx +++ b/src/plugins/vis_types/gauge/public/vis_type/goal.tsx @@ -90,6 +90,7 @@ export const getGoalVisTypeDefinition = ( '!geo_bounds', '!filtered_metric', '!single_percentile', + '!single_percentile_rank', ], defaults: [{ schema: 'metric', type: 'count' }], }, diff --git a/src/plugins/vis_types/heatmap/public/vis_type/heatmap.tsx b/src/plugins/vis_types/heatmap/public/vis_type/heatmap.tsx index 4c62af96c9b40..6f711eb2667df 100644 --- a/src/plugins/vis_types/heatmap/public/vis_type/heatmap.tsx +++ b/src/plugins/vis_types/heatmap/public/vis_type/heatmap.tsx @@ -88,6 +88,7 @@ export const getHeatmapVisTypeDefinition = ({ 'top_hits', '!filtered_metric', '!single_percentile', + '!single_percentile_rank', ], defaults: [{ schema: 'metric', type: 'count' }], }, diff --git a/src/plugins/vis_types/metric/public/metric_vis_type.ts b/src/plugins/vis_types/metric/public/metric_vis_type.ts index 7c141131fa8e5..15ec40d3bd612 100644 --- a/src/plugins/vis_types/metric/public/metric_vis_type.ts +++ b/src/plugins/vis_types/metric/public/metric_vis_type.ts @@ -66,6 +66,7 @@ export const createMetricVisTypeDefinition = (): VisTypeDefinition => '!geo_bounds', '!filtered_metric', '!single_percentile', + '!single_percentile_rank', ], aggSettings: { top_hits: { diff --git a/src/plugins/vis_types/table/public/table_vis_type.ts b/src/plugins/vis_types/table/public/table_vis_type.ts index 80c9d7bb9f00d..b4e7a2274852e 100644 --- a/src/plugins/vis_types/table/public/table_vis_type.ts +++ b/src/plugins/vis_types/table/public/table_vis_type.ts @@ -48,7 +48,13 @@ export const tableVisTypeDefinition: VisTypeDefinition = { title: i18n.translate('visTypeTable.tableVisEditorConfig.schemas.metricTitle', { defaultMessage: 'Metric', }), - aggFilter: ['!geo_centroid', '!geo_bounds', '!filtered_metric', '!single_percentile'], + aggFilter: [ + '!geo_centroid', + '!geo_bounds', + '!filtered_metric', + '!single_percentile', + '!single_percentile_rank', + ], aggSettings: { top_hits: { allowStrings: true, diff --git a/src/plugins/vis_types/tagcloud/public/tag_cloud_type.ts b/src/plugins/vis_types/tagcloud/public/tag_cloud_type.ts index c278c47dd9022..35b7845ec515f 100644 --- a/src/plugins/vis_types/tagcloud/public/tag_cloud_type.ts +++ b/src/plugins/vis_types/tagcloud/public/tag_cloud_type.ts @@ -62,6 +62,7 @@ export const getTagCloudVisTypeDefinition = ({ palettes }: TagCloudVisDependenci '!geo_centroid', '!filtered_metric', '!single_percentile', + '!single_percentile_rank', ], defaults: [{ schema: 'metric', type: 'count' }], }, diff --git a/src/plugins/vis_types/timeseries/public/trigger_action/get_series.test.ts b/src/plugins/vis_types/timeseries/public/trigger_action/get_series.test.ts index 3a68e2d63f25e..cfd858a345669 100644 --- a/src/plugins/vis_types/timeseries/public/trigger_action/get_series.test.ts +++ b/src/plugins/vis_types/timeseries/public/trigger_action/get_series.test.ts @@ -338,7 +338,7 @@ describe('getSeries', () => { const config = getSeries(metric, 1); expect(config).toStrictEqual([ { - agg: 'percentile_ranks', + agg: 'percentile_rank', color: 'rgba(211,96,134,1)', fieldName: 'day_of_week_i', isFullReference: false, @@ -347,7 +347,7 @@ describe('getSeries', () => { }, }, { - agg: 'percentile_ranks', + agg: 'percentile_rank', color: 'rgba(155,33,230,1)', fieldName: 'day_of_week_i', isFullReference: false, @@ -356,7 +356,7 @@ describe('getSeries', () => { }, }, { - agg: 'percentile_ranks', + agg: 'percentile_rank', color: '#68BC00', fieldName: 'day_of_week_i', isFullReference: false, @@ -549,7 +549,7 @@ describe('getSeries', () => { isFullReference: true, params: { formula: - 'percentile_ranks(day_of_week_i, value=1) + percentile_ranks(day_of_week_i, value=5) + average(day_of_week_i)', + 'percentile_rank(day_of_week_i, value=1) + percentile_rank(day_of_week_i, value=5) + average(day_of_week_i)', }, }, ]); diff --git a/src/plugins/vis_types/timeseries/public/trigger_action/get_series.ts b/src/plugins/vis_types/timeseries/public/trigger_action/get_series.ts index 20538dcc66aeb..e180df5b4c1a9 100644 --- a/src/plugins/vis_types/timeseries/public/trigger_action/get_series.ts +++ b/src/plugins/vis_types/timeseries/public/trigger_action/get_series.ts @@ -114,7 +114,7 @@ export const getSeries = ( break; } case 'cumulative_sum': { - // percentile and percentile_ranks value is derived from the field Id. It has the format xxx-xxx-xxx-xxx[percentile] + // percentile and percentile_rank value is derived from the field Id. It has the format xxx-xxx-xxx-xxx[percentile] const [fieldId, meta] = metrics[metricIdx]?.field?.split('[') ?? []; const subFunctionMetric = metrics.find((metric) => metric.id === fieldId); if (!subFunctionMetric || subFunctionMetric.type === 'static') { diff --git a/src/plugins/vis_types/timeseries/public/trigger_action/metrics_helpers.test.ts b/src/plugins/vis_types/timeseries/public/trigger_action/metrics_helpers.test.ts index 1211f7da7dd18..292515adf21e6 100644 --- a/src/plugins/vis_types/timeseries/public/trigger_action/metrics_helpers.test.ts +++ b/src/plugins/vis_types/timeseries/public/trigger_action/metrics_helpers.test.ts @@ -89,21 +89,21 @@ describe('getPercentileRankSeries', () => { const config = getPercentileRankSeries(values, colors, 'day_of_week_i'); expect(config).toStrictEqual([ { - agg: 'percentile_ranks', + agg: 'percentile_rank', color: '#68BC00', fieldName: 'day_of_week_i', isFullReference: false, params: { value: '1' }, }, { - agg: 'percentile_ranks', + agg: 'percentile_rank', color: 'rgba(0,63,188,1)', fieldName: 'day_of_week_i', isFullReference: false, params: { value: '5' }, }, { - agg: 'percentile_ranks', + agg: 'percentile_rank', color: 'rgba(188,38,0,1)', fieldName: 'day_of_week_i', isFullReference: false, @@ -184,7 +184,7 @@ describe('getParentPipelineSeries', () => { params: { value: 400, }, - pipelineAggType: 'percentile_ranks', + pipelineAggType: 'percentile_rank', }, ]); }); diff --git a/src/plugins/vis_types/timeseries/public/trigger_action/metrics_helpers.ts b/src/plugins/vis_types/timeseries/public/trigger_action/metrics_helpers.ts index 35e8331188a67..e3d8fa0434cbd 100644 --- a/src/plugins/vis_types/timeseries/public/trigger_action/metrics_helpers.ts +++ b/src/plugins/vis_types/timeseries/public/trigger_action/metrics_helpers.ts @@ -28,7 +28,7 @@ export const getPercentileRankSeries = ( ) => { return values?.map((value, index) => { return { - agg: 'percentile_ranks', + agg: 'percentile_rank', isFullReference: false, color: colors?.[index], fieldName: fieldName ?? 'document', @@ -93,7 +93,7 @@ export const computeParentSeries = ( ...(currentMetric.window && { window: currentMetric.window }), ...(timeScale && { timeScale }), ...(pipelineAgg === 'percentile' && meta && { percentile: meta }), - ...(pipelineAgg === 'percentile_ranks' && meta && { value: meta }), + ...(pipelineAgg === 'percentile_rank' && meta && { value: meta }), }, }, ]; @@ -168,7 +168,7 @@ export const getParentPipelineSeriesFormula = ( if (additionalPipelineAggMap.name === 'percentile' && nestedMetaValue) { additionalFunctionArgs = `, percentile=${nestedMetaValue}`; } - if (additionalPipelineAggMap.name === 'percentile_ranks' && nestedMetaValue) { + if (additionalPipelineAggMap.name === 'percentile_rank' && nestedMetaValue) { additionalFunctionArgs = `, value=${nestedMetaValue}`; } formula = `${aggMap.name}(${pipelineAgg}(${additionalPipelineAggMap.name}(${ @@ -179,7 +179,7 @@ export const getParentPipelineSeriesFormula = ( if (pipelineAgg === 'percentile' && percentileValue) { additionalFunctionArgs = `, percentile=${percentileValue}`; } - if (pipelineAgg === 'percentile_ranks' && percentileValue) { + if (pipelineAgg === 'percentile_rank' && percentileValue) { additionalFunctionArgs = `, value=${percentileValue}`; } if (pipelineAgg === 'filter_ratio') { @@ -238,12 +238,12 @@ export const getSiblingPipelineSeriesFormula = ( }))${minMax})`; } else { let additionalFunctionArgs; - // handle percentile and percentile_ranks + // handle percentile and percentile_rank const nestedMetaValue = Number(nestedMeta?.replace(']', '')); if (pipelineAggMap.name === 'percentile' && nestedMetaValue) { additionalFunctionArgs = `, percentile=${nestedMetaValue}`; } - if (pipelineAggMap.name === 'percentile_ranks' && nestedMetaValue) { + if (pipelineAggMap.name === 'percentile_rank' && nestedMetaValue) { additionalFunctionArgs = `, value=${nestedMetaValue}`; } if (currentMetric.type === 'positive_only') { diff --git a/src/plugins/vis_types/timeseries/public/trigger_action/supported_metrics.ts b/src/plugins/vis_types/timeseries/public/trigger_action/supported_metrics.ts index 803c04c03b3f5..30b6f47da5f7e 100644 --- a/src/plugins/vis_types/timeseries/public/trigger_action/supported_metrics.ts +++ b/src/plugins/vis_types/timeseries/public/trigger_action/supported_metrics.ts @@ -73,7 +73,7 @@ export const SUPPORTED_METRICS: { [key: string]: AggOptions } = { isFullReference: false, }, percentile_rank: { - name: 'percentile_ranks', + name: 'percentile_rank', isFullReference: false, }, sum: { diff --git a/src/plugins/vis_types/xy/public/vis_types/area.ts b/src/plugins/vis_types/xy/public/vis_types/area.ts index 01668680ac24c..84a6a65d2753a 100644 --- a/src/plugins/vis_types/xy/public/vis_types/area.ts +++ b/src/plugins/vis_types/xy/public/vis_types/area.ts @@ -136,7 +136,13 @@ export const areaVisTypeDefinition = { title: i18n.translate('visTypeXy.area.metricsTitle', { defaultMessage: 'Y-axis', }), - aggFilter: ['!geo_centroid', '!geo_bounds', '!filtered_metric', '!single_percentile'], + aggFilter: [ + '!geo_centroid', + '!geo_bounds', + '!filtered_metric', + '!single_percentile', + '!single_percentile_rank', + ], min: 1, defaults: [{ schema: 'metric', type: 'count' }], }, diff --git a/src/plugins/vis_types/xy/public/vis_types/histogram.ts b/src/plugins/vis_types/xy/public/vis_types/histogram.ts index 5405ac31eba42..dd1ee2836b10f 100644 --- a/src/plugins/vis_types/xy/public/vis_types/histogram.ts +++ b/src/plugins/vis_types/xy/public/vis_types/histogram.ts @@ -140,7 +140,13 @@ export const histogramVisTypeDefinition = { defaultMessage: 'Y-axis', }), min: 1, - aggFilter: ['!geo_centroid', '!geo_bounds', '!filtered_metric', '!single_percentile'], + aggFilter: [ + '!geo_centroid', + '!geo_bounds', + '!filtered_metric', + '!single_percentile', + '!single_percentile_rank', + ], defaults: [{ schema: 'metric', type: 'count' }], }, { diff --git a/src/plugins/vis_types/xy/public/vis_types/horizontal_bar.ts b/src/plugins/vis_types/xy/public/vis_types/horizontal_bar.ts index aaf4ef2e2d51b..dda1ead899faf 100644 --- a/src/plugins/vis_types/xy/public/vis_types/horizontal_bar.ts +++ b/src/plugins/vis_types/xy/public/vis_types/horizontal_bar.ts @@ -139,7 +139,13 @@ export const horizontalBarVisTypeDefinition = { defaultMessage: 'Y-axis', }), min: 1, - aggFilter: ['!geo_centroid', '!geo_bounds', '!filtered_metric', '!single_percentile'], + aggFilter: [ + '!geo_centroid', + '!geo_bounds', + '!filtered_metric', + '!single_percentile', + '!single_percentile_rank', + ], defaults: [{ schema: 'metric', type: 'count' }], }, { diff --git a/src/plugins/vis_types/xy/public/vis_types/line.ts b/src/plugins/vis_types/xy/public/vis_types/line.ts index bd528b6565ab2..a4ad14d7f5442 100644 --- a/src/plugins/vis_types/xy/public/vis_types/line.ts +++ b/src/plugins/vis_types/xy/public/vis_types/line.ts @@ -135,7 +135,13 @@ export const lineVisTypeDefinition = { name: 'metric', title: i18n.translate('visTypeXy.line.metricTitle', { defaultMessage: 'Y-axis' }), min: 1, - aggFilter: ['!geo_centroid', '!geo_bounds', '!filtered_metric', '!single_percentile'], + aggFilter: [ + '!geo_centroid', + '!geo_bounds', + '!filtered_metric', + '!single_percentile', + '!single_percentile_rank', + ], defaults: [{ schema: 'metric', type: 'count' }], }, { diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_panel.test.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_panel.test.tsx index 037251cc29aed..25ad7dfb97b4c 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_panel.test.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/dimension_panel/dimension_panel.test.tsx @@ -1942,7 +1942,7 @@ describe('IndexPatternDimensionEditorPanel', () => { 'Minimum', 'Moving average', 'Percentile', - 'Percentile ranks', + 'Percentile rank', 'Sum', 'Unique count', ]); diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/column_types.ts b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/column_types.ts index ec2b74295df7d..21ba19d5fb047 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/column_types.ts +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/column_types.ts @@ -38,12 +38,6 @@ export interface FieldBasedIndexPatternColumn extends BaseIndexPatternColumn { sourceField: string; } -export interface FieldBasedIndexPatternColumnMultipleValues extends FieldBasedIndexPatternColumn { - params: { - value: number; - }; -} - export interface ReferenceBasedIndexPatternColumn extends FormattedIndexPatternColumn { references: string[]; } diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/math_examples.md b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/math_examples.md index 6b762e4804ed0..b2620ce9b06af 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/math_examples.md +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/formula/math_examples.md @@ -11,7 +11,7 @@ differences(count()) differences(sum(bytes), normalize_unit='1s') last_value(bytes, sort=timestamp) percentile(bytes, percent=95) -percentile_ranks(bytes, value=1024) +percentile_rank(bytes, value=1024) Adding features beyond what we already support. New features are: diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile_ranks.test.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile_ranks.test.tsx index a9e30cd92cbbf..4812c782a5f67 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile_ranks.test.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile_ranks.test.tsx @@ -75,9 +75,8 @@ describe('percentile ranks', () => { label: 'Percentile (100) of a', dataType: 'number', isBucketed: false, - isMultiValuesAggregation: true, sourceField: 'a', - operationType: 'percentile_ranks', + operationType: 'percentile_rank', params: { value: 100, }, @@ -100,7 +99,6 @@ describe('percentile ranks', () => { ).toEqual({ dataType: 'number', isBucketed: false, - isMultiValuesAggregation: true, scale: 'ratio', }); }); @@ -118,7 +116,6 @@ describe('percentile ranks', () => { ).toEqual({ dataType: 'number', isBucketed: false, - isMultiValuesAggregation: true, scale: 'ratio', }); }); @@ -151,7 +148,7 @@ describe('percentile ranks', () => { expect(esAggsFn).toEqual( expect.objectContaining({ arguments: expect.objectContaining({ - values: [100], + value: [100], field: ['a'], }), }) @@ -162,7 +159,7 @@ describe('percentile ranks', () => { describe('onFieldChange', () => { it('should change correctly to new field', () => { const oldColumn: PercentileRanksIndexPatternColumn = { - operationType: 'percentile_ranks', + operationType: 'percentile_rank', sourceField: 'bytes', label: 'Percentile rank (100) of bytes', isBucketed: true, @@ -256,7 +253,7 @@ describe('percentile ranks', () => { sourceField: 'response_time', isBucketed: false, dataType: 'number', - operationType: 'percentile_ranks', + operationType: 'percentile_rank', params: { value: 10, }, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile_ranks.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile_ranks.tsx index 3e27dade79b7f..f153b2aca669b 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile_ranks.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/percentile_ranks.tsx @@ -20,14 +20,16 @@ import { isColumnOfType, combineErrorMessages, } from './helpers'; -import { FieldBasedIndexPatternColumnMultipleValues } from './column_types'; +import { FieldBasedIndexPatternColumn } from './column_types'; import { adjustTimeScaleLabelSuffix } from '../time_scale_utils'; import { useDebouncedValue } from '../../../shared_components'; import { getDisallowedPreviousShiftMessage } from '../../time_shift_utils'; -export interface PercentileRanksIndexPatternColumn - extends FieldBasedIndexPatternColumnMultipleValues { - operationType: 'percentile_ranks'; +export interface PercentileRanksIndexPatternColumn extends FieldBasedIndexPatternColumn { + operationType: 'percentile_rank'; + params: { + value: number; + }; } function ofName(name: string, value: number, timeShift: string | undefined) { @@ -52,9 +54,9 @@ export const percentileRanksOperation: OperationDefinition< 'field', { value: number } > = { - type: 'percentile_ranks', - displayName: i18n.translate('xpack.lens.indexPattern.percentileRanks', { - defaultMessage: 'Percentile ranks', + type: 'percentile_rank', + displayName: i18n.translate('xpack.lens.indexPattern.percentileRank', { + defaultMessage: 'Percentile rank', }), input: 'field', operationParams: [ @@ -72,7 +74,6 @@ export const percentileRanksOperation: OperationDefinition< return { dataType: 'number', isBucketed: false, - isMultiValuesAggregation: true, scale: 'ratio', }; } @@ -92,7 +93,7 @@ export const percentileRanksOperation: OperationDefinition< buildColumn: ({ field, previousColumn, indexPattern }, columnParams) => { const existingPercentileRanksParam = previousColumn && - isColumnOfType('percentile_ranks', previousColumn) && + isColumnOfType('percentile_rank', previousColumn) && previousColumn.params.value; const newPercentileRanksParam = columnParams?.value ?? (existingPercentileRanksParam || DEFAULT_PERCENTILE_RANKS_VALUE); @@ -103,8 +104,7 @@ export const percentileRanksOperation: OperationDefinition< previousColumn?.timeShift ), dataType: 'number', - operationType: 'percentile_ranks', - isMultiValuesAggregation: true, + operationType: 'percentile_rank', sourceField: field.name, isBucketed: false, scale: 'ratio', @@ -124,14 +124,14 @@ export const percentileRanksOperation: OperationDefinition< }; }, toEsAggsFn: (column, columnId, _indexPattern) => { - return buildExpressionFunction( - 'aggPercentileRanks', + return buildExpressionFunction( + 'aggSinglePercentileRank', { id: columnId, enabled: true, schema: 'metric', field: column.sourceField, - values: [column.params.value], + value: column.params.value, // time shift is added to wrapping aggFilteredMetric if filter is set timeShift: column.filter ? undefined : column.timeShift, } @@ -139,10 +139,7 @@ export const percentileRanksOperation: OperationDefinition< }, getErrorMessage: (layer, columnId, indexPattern) => combineErrorMessages([ - getInvalidFieldMessage( - layer.columns[columnId] as FieldBasedIndexPatternColumnMultipleValues, - indexPattern - ), + getInvalidFieldMessage(layer.columns[columnId] as FieldBasedIndexPatternColumn, indexPattern), getDisallowedPreviousShiftMessage(layer, columnId), ]), paramEditor: function PercentileParamEditor({ @@ -238,7 +235,7 @@ export const percentileRanksOperation: OperationDefinition< Returns the percentage of values which are below a certain value. For example, if a value is greater than or equal to 95% of the observed values it is said to be at the 95th percentile rank Example: Get the percentage of values which are below of 100: -\`percentile_ranks(bytes, value=100)\` +\`percentile_rank(bytes, value=100)\` `, }), }, diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/index.tsx b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/index.tsx index 26b460fea41c2..2021f6132c7f9 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/index.tsx +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/definitions/terms/index.tsx @@ -24,10 +24,7 @@ import { buildExpressionFunction } from '@kbn/expressions-plugin/public'; import { insertOrReplaceColumn, updateColumnParam, updateDefaultLabels } from '../../layer_helpers'; import type { DataType } from '../../../../types'; import { OperationDefinition } from '..'; -import { - FieldBasedIndexPatternColumn, - FieldBasedIndexPatternColumnMultipleValues, -} from '../column_types'; +import { FieldBasedIndexPatternColumn } from '../column_types'; import { ValuesInput } from './values_input'; import { getInvalidFieldMessage } from '../helpers'; import { FieldInputs, getInputFieldErrorMessage, MAX_MULTI_FIELDS_SIZE } from './field_inputs'; @@ -238,24 +235,6 @@ export const termsOperation: OperationDefinition { ); }); - it('should reflect multivalue aggs terms params correctly', () => { - const newLayer = { - ...layer, - columns: { - ...layer.columns, - col2: { - ...layer.columns.col2, - isMultiValuesAggregation: true, - params: { - value: 100, - }, - }, - }, - }; - const termsColumn = layer.columns.col1 as TermsIndexPatternColumn; - const esAggsFn = termsOperation.toEsAggsFn( - { - ...termsColumn, - params: { ...termsColumn.params, orderBy: { type: 'column', columnId: 'col2' } }, - }, - 'col1', - {} as IndexPattern, - newLayer, - uiSettingsMock, - ['col1', 'col2'] - ); - expect(esAggsFn).toEqual( - expect.objectContaining({ - function: 'aggTerms', - arguments: expect.objectContaining({ - orderBy: ['1.100'], - }), - }) - ); - }); - it('should not enable missing bucket if other bucket is not set', () => { const termsColumn = layer.columns.col1 as TermsIndexPatternColumn; const esAggsFn = termsOperation.toEsAggsFn( diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/operations/operations.test.ts b/x-pack/plugins/lens/public/indexpattern_datasource/operations/operations.test.ts index 3169ca98daf1d..8fb89d46cee2c 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/operations/operations.test.ts +++ b/x-pack/plugins/lens/public/indexpattern_datasource/operations/operations.test.ts @@ -93,7 +93,7 @@ describe('getOperationTypesForField', () => { 'max', 'unique_count', 'percentile', - 'percentile_ranks', + 'percentile_rank', 'last_value', ]); }); @@ -118,7 +118,7 @@ describe('getOperationTypesForField', () => { 'max', 'unique_count', 'percentile', - 'percentile_ranks', + 'percentile_rank', 'last_value', ]); }); @@ -371,6 +371,11 @@ describe('getOperationTypesForField', () => { "operationType": "percentile", "type": "field", }, + Object { + "field": "bytes", + "operationType": "percentile_rank", + "type": "field", + }, Object { "field": "bytes", "operationType": "last_value", @@ -410,21 +415,6 @@ describe('getOperationTypesForField', () => { }, ], }, - Object { - "operationMetaData": Object { - "dataType": "number", - "isBucketed": false, - "isMultiValuesAggregation": true, - "scale": "ratio", - }, - "operations": Array [ - Object { - "field": "bytes", - "operationType": "percentile_ranks", - "type": "field", - }, - ], - }, Object { "operationMetaData": Object { "dataType": "string", diff --git a/x-pack/plugins/lens/public/indexpattern_datasource/to_expression.ts b/x-pack/plugins/lens/public/indexpattern_datasource/to_expression.ts index d64e96b5518b3..0307e748ac1fb 100644 --- a/x-pack/plugins/lens/public/indexpattern_datasource/to_expression.ts +++ b/x-pack/plugins/lens/public/indexpattern_datasource/to_expression.ts @@ -24,10 +24,7 @@ import { GenericIndexPatternColumn } from './indexpattern'; import { operationDefinitionMap } from './operations'; import { IndexPattern, IndexPatternPrivateState, IndexPatternLayer } from './types'; import { DateHistogramIndexPatternColumn, RangeIndexPatternColumn } from './operations/definitions'; -import { - FormattedIndexPatternColumn, - FieldBasedIndexPatternColumnMultipleValues, -} from './operations/definitions/column_types'; +import { FormattedIndexPatternColumn } from './operations/definitions/column_types'; import { isColumnFormatted, isColumnOfType } from './operations/definitions/helpers'; type OriginalColumn = { id: string } & GenericIndexPatternColumn; @@ -168,22 +165,9 @@ function getExpressionForLayer( } const idMap = esAggEntries.reduce((currentIdMap, [colId, column], index) => { - let esAggsId = window.ELASTIC_LENS_DELAY_SECONDS + const esAggsId = window.ELASTIC_LENS_DELAY_SECONDS ? `col-${index + (column.isBucketed ? 0 : 1)}-${index}` : `col-${index}-${index}`; - // for aggregations that accept multiple values, the id also contains the - // values that are being aggregated over, for example for a percentile_ranks agg - // of 400 this must be specified as `col-0-0.400` - if ( - column.isMultiValuesAggregation && - !column.filter && - 'params' in column && - column.params && - 'value' in column.params - ) { - const params = column.params as FieldBasedIndexPatternColumnMultipleValues['params']; - esAggsId += `.${params.value}`; - } return { ...currentIdMap, diff --git a/x-pack/plugins/lens/public/types.ts b/x-pack/plugins/lens/public/types.ts index 52dd34b77db83..0b34916e9d94d 100644 --- a/x-pack/plugins/lens/public/types.ts +++ b/x-pack/plugins/lens/public/types.ts @@ -524,7 +524,6 @@ export interface OperationMetadata { isStaticValue?: boolean; // There are some aggregations, such as the percentile ranks, that accept multi values // and they need to be treated with a different way. This flag is used to identify these operations - isMultiValuesAggregation?: boolean; } /**