From 9c0c22db964932715415eed75a0ceb197ec1735c Mon Sep 17 00:00:00 2001 From: Marco Liberati Date: Thu, 25 Jan 2024 18:00:23 +0100 Subject: [PATCH] [ES|QL] Add support for mv_first, mv_last, to_geoshape, to_cartesianshape (#175518) ## Summary Add missing functions to ES|QL validation/autocomplete support. ### Checklist - [x] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --- .../src/esql/lib/ast/definitions/functions.ts | 58 ++++++++++++++++++- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/packages/kbn-monaco/src/esql/lib/ast/definitions/functions.ts b/packages/kbn-monaco/src/esql/lib/ast/definitions/functions.ts index 932f913f9925b..f7919061f423c 100644 --- a/packages/kbn-monaco/src/esql/lib/ast/definitions/functions.ts +++ b/packages/kbn-monaco/src/esql/lib/ast/definitions/functions.ts @@ -267,6 +267,19 @@ export const evalFunctionsDefinitions: FunctionDefinition[] = [ }, ], }, + { + name: 'to_cartesianshape', + description: i18n.translate('monaco.esql.definitions.toCartesianshapeDoc', { + defaultMessage: 'Converts an input value to a cartesian_shape value.', + }), + signatures: [ + { + params: [{ name: 'field', type: 'any' }], + returnType: 'cartesian_shape', + examples: [`from index | EVAL cartesianshape = to_cartesianshape(field)`], + }, + ], + }, { name: 'to_datetime', alias: ['to_dt'], @@ -321,6 +334,19 @@ export const evalFunctionsDefinitions: FunctionDefinition[] = [ }, ], }, + { + name: 'to_geoshape', + description: i18n.translate('monaco.esql.definitions.toGeoshapeDoc', { + defaultMessage: 'Converts an input value to a geo_shape value.', + }), + signatures: [ + { + params: [{ name: 'field', type: 'any' }], + returnType: 'geo_shape', + examples: [`from index | EVAL geoshape = to_geoshape(field)`], + }, + ], + }, { name: 'to_integer', alias: ['to_int'], @@ -849,7 +875,7 @@ export const evalFunctionsDefinitions: FunctionDefinition[] = [ { params: [{ name: 'multivalue', type: 'number[]' }], returnType: 'number', - examples: ['row a = [1, 2, 3] | mv_avg(a)'], + examples: ['row a = [1, 2, 3] | eval mv_avg(a)'], }, ], }, @@ -866,7 +892,7 @@ export const evalFunctionsDefinitions: FunctionDefinition[] = [ { name: 'delimeter', type: 'string' }, ], returnType: 'string', - examples: ['row a = ["1", "2", "3"] | mv_concat(a, ", ")'], + examples: ['row a = ["1", "2", "3"] | eval mv_concat(a, ", ")'], }, ], }, @@ -897,6 +923,34 @@ export const evalFunctionsDefinitions: FunctionDefinition[] = [ }, ], }, + { + name: 'mv_first', + description: i18n.translate('monaco.esql.definitions.mvFirstDoc', { + defaultMessage: + 'Reduce a multivalued field to a single valued field containing the first value.', + }), + signatures: [ + { + params: [{ name: 'multivalue', type: 'any' }], + returnType: 'any', + examples: ['row a = [1, 2, 3] | eval one = mv_first(a)'], + }, + ], + }, + { + name: 'mv_last', + description: i18n.translate('monaco.esql.definitions.mvLastDoc', { + defaultMessage: + 'Reduce a multivalued field to a single valued field containing the last value.', + }), + signatures: [ + { + params: [{ name: 'multivalue', type: 'any' }], + returnType: 'any', + examples: ['row a = [1, 2, 3] | eval three = mv_last(a)'], + }, + ], + }, { name: 'mv_max', description: i18n.translate('monaco.esql.definitions.mvMaxDoc', {