Skip to content

Commit

Permalink
[ES|QL] Add support for mv_first, mv_last, to_geoshape, to_cartesians…
Browse files Browse the repository at this point in the history
…hape (elastic#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
  • Loading branch information
dej611 authored Jan 25, 2024
1 parent 2970f75 commit 9c0c22d
Showing 1 changed file with 56 additions and 2 deletions.
58 changes: 56 additions & 2 deletions packages/kbn-monaco/src/esql/lib/ast/definitions/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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)'],
},
],
},
Expand All @@ -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, ", ")'],
},
],
},
Expand Down Expand Up @@ -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', {
Expand Down

0 comments on commit 9c0c22d

Please sign in to comment.