Skip to content

Commit 1353e42

Browse files
[ES|QL] Update function metadata (elastic#226710)
This PR updates the function definitions and inline docs based on the latest metadata from Elasticsearch.
1 parent dbf92f4 commit 1353e42

6 files changed

Lines changed: 48 additions & 29 deletions

File tree

src/platform/packages/private/kbn-language-documentation/src/sections/generated/aggregation_functions.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,12 @@ export const functions = {
160160
### MEDIAN
161161
The value that is greater than half of all values and less than half of all values, also known as the 50% [\`PERCENTILE\`](https://www.elastic.co/docs/reference/query-languages/esql/functions-operators/aggregation-functions#esql-percentile).
162162
163+
Note: Like [\`PERCENTILE\`](https://www.elastic.co/docs/reference/query-languages/esql/functions-operators/aggregation-functions#esql-percentile), \`MEDIAN\` is [usually approximate](https://www.elastic.co/docs/reference/query-languages/esql/functions-operators/aggregation-functions#esql-percentile-approximate).
164+
163165
\`\`\`esql
164166
FROM employees
165167
| STATS MEDIAN(salary), PERCENTILE(salary, 50)
166168
\`\`\`
167-
Note: Like [\`PERCENTILE\`](https://www.elastic.co/docs/reference/query-languages/esql/functions-operators/aggregation-functions#esql-percentile), \`MEDIAN\` is [usually approximate](https://www.elastic.co/docs/reference/query-languages/esql/functions-operators/aggregation-functions#esql-percentile-approximate).
168169
`,
169170
description:
170171
'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)',
@@ -194,11 +195,12 @@ export const functions = {
194195
195196
It is calculated as the median of each data point’s deviation from the median of the entire sample. That is, for a random variable \`X\`, the median absolute deviation is \`median(|median(X) - X|)\`.
196197
198+
Note: Like [\`PERCENTILE\`](https://www.elastic.co/docs/reference/query-languages/esql/functions-operators/aggregation-functions#esql-percentile), \`MEDIAN_ABSOLUTE_DEVIATION\` is [usually approximate](https://www.elastic.co/docs/reference/query-languages/esql/functions-operators/aggregation-functions#esql-percentile-approximate).
199+
197200
\`\`\`esql
198201
FROM employees
199202
| STATS MEDIAN(salary), MEDIAN_ABSOLUTE_DEVIATION(salary)
200203
\`\`\`
201-
Note: Like [\`PERCENTILE\`](https://www.elastic.co/docs/reference/query-languages/esql/functions-operators/aggregation-functions#esql-percentile), \`MEDIAN_ABSOLUTE_DEVIATION\` is [usually approximate](https://www.elastic.co/docs/reference/query-languages/esql/functions-operators/aggregation-functions#esql-percentile-approximate).
202204
`,
203205
description:
204206
'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)',

src/platform/packages/private/kbn-language-documentation/src/sections/generated/operators.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export const functions = {
3838
defaultMessage: `
3939
### ADD \`+\`
4040
Add two numbers together. If either field is [multivalued](https://www.elastic.co/docs/reference/query-languages/esql/esql-multivalued-fields) then the result is \`null\`.
41-
4241
`,
4342
description:
4443
'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)',
@@ -240,6 +239,12 @@ export const functions = {
240239
Returns \`false\` if the value is \`NULL\`, \`true\` otherwise.
241240
242241
Note: If a field is only in some documents it will be \`NULL\` in the documents that did not contain it.
242+
243+
\`\`\`esql
244+
FROM employees
245+
| WHERE is_rehired IS NOT NULL
246+
| STATS COUNT(emp_no)
247+
\`\`\`
243248
`,
244249
description:
245250
'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)',
@@ -268,6 +273,11 @@ export const functions = {
268273
Returns \`true\` if the value is \`NULL\`, \`false\` otherwise.
269274
270275
Note: If a field is only in some documents it will be \`NULL\` in the documents that did not contain it.
276+
277+
\`\`\`esql
278+
FROM employees
279+
| WHERE birth_date IS NULL
280+
\`\`\`
271281
`,
272282
description:
273283
'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)',
@@ -352,8 +362,7 @@ export const functions = {
352362
Use \`LIKE\` to filter data based on string patterns using wildcards. \`LIKE\`
353363
usually acts on a field placed on the left-hand side of the operator, but it can
354364
also act on a constant (literal) expression. The right-hand side of the operator
355-
represents the pattern or a list of patterns. If a list of patterns is provided,
356-
the expression will return true if any of the patterns match.
365+
represents the pattern.
357366
358367
The following wildcard characters are supported:
359368
@@ -430,7 +439,6 @@ export const functions = {
430439
defaultMessage: `
431440
### MODULO \`%\`
432441
Divide one number by another and return the remainder. If either field is [multivalued](https://www.elastic.co/docs/reference/query-languages/esql/esql-multivalued-fields) then the result is \`null\`.
433-
434442
`,
435443
description:
436444
'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)',
@@ -457,7 +465,6 @@ export const functions = {
457465
defaultMessage: `
458466
### MULTIPLY \`*\`
459467
Multiply two numbers together. If either field is [multivalued](https://www.elastic.co/docs/reference/query-languages/esql/esql-multivalued-fields) then the result is \`null\`.
460-
461468
`,
462469
description:
463470
'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)',
@@ -484,7 +491,6 @@ export const functions = {
484491
defaultMessage: `
485492
### NEGATE \`-\`
486493
Returns the negation of the argument.
487-
488494
`,
489495
description:
490496
'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)',
@@ -574,7 +580,6 @@ export const functions = {
574580
defaultMessage: `
575581
### SUBTRACT \`-\`
576582
Subtract one number from another. If either field is [multivalued](https://www.elastic.co/docs/reference/query-languages/esql/esql-multivalued-fields) then the result is \`null\`.
577-
578583
`,
579584
description:
580585
'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)',

src/platform/packages/private/kbn-language-documentation/src/sections/generated/scalar_functions.tsx

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,14 @@ export const functions = {
187187
### BIT LENGTH
188188
Returns the bit length of a string.
189189
190+
Note: All strings are in UTF-8, so a single character can use multiple bytes.
191+
190192
\`\`\`esql
191193
FROM airports
192194
| WHERE country == "India"
193195
| KEEP city
194196
| EVAL fn_length = LENGTH(city), fn_bit_length = BIT_LENGTH(city)
195197
\`\`\`
196-
Note: All strings are in UTF-8, so a single character can use multiple bytes.
197198
`,
198199
description:
199200
'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)',
@@ -221,13 +222,14 @@ export const functions = {
221222
### BYTE LENGTH
222223
Returns the byte length of a string.
223224
225+
Note: All strings are in UTF-8, so a single character can use multiple bytes.
226+
224227
\`\`\`esql
225228
FROM airports
226229
| WHERE country == "India"
227230
| KEEP city
228231
| EVAL fn_length = LENGTH(city), fn_byte_length = BYTE_LENGTH(city)
229232
\`\`\`
230-
Note: All strings are in UTF-8, so a single character can use multiple bytes.
231233
`,
232234
description:
233235
'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)',
@@ -319,11 +321,12 @@ export const functions = {
319321
### CEIL
320322
Round a number up to the nearest integer.
321323
324+
Note: This is a noop for \`long\` (including unsigned) and \`integer\`. For \`double\` this picks the closest \`double\` value to the integer similar to [Math.ceil](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Math.html#ceil(double)).
325+
322326
\`\`\`esql
323327
ROW a=1.8
324328
| EVAL a=CEIL(a)
325329
\`\`\`
326-
Note: This is a noop for \`long\` (including unsigned) and \`integer\`. For \`double\` this picks the closest \`double\` value to the integer similar to [Math.ceil](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Math.html#ceil(double)).
327330
`,
328331
description:
329332
'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)',
@@ -747,13 +750,14 @@ export const functions = {
747750
### FLOOR
748751
Round a number down to the nearest integer.
749752
753+
Note: This is a noop for \`long\` (including unsigned) and \`integer\`.
754+
For \`double\` this picks the closest \`double\` value to the integer
755+
similar to [Math.floor](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Math.html#floor(double)).
756+
750757
\`\`\`esql
751758
ROW a=1.8
752759
| EVAL a=FLOOR(a)
753760
\`\`\`
754-
Note: This is a noop for \`long\` (including unsigned) and \`integer\`.
755-
For \`double\` this picks the closest \`double\` value to the integer
756-
similar to [Math.floor](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Math.html#floor(double)).
757761
`,
758762
description:
759763
'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)',
@@ -813,11 +817,12 @@ export const functions = {
813817
Returns the maximum value from multiple columns. This is similar to [\`MV_MAX\`](https://www.elastic.co/docs/reference/query-languages/esql/functions-operators/mv-functions#esql-mv_max)
814818
except it is intended to run on multiple columns at once.
815819
820+
Note: When run on \`keyword\` or \`text\` fields, this returns the last string in alphabetical order. When run on \`boolean\` columns this will return \`true\` if any values are \`true\`.
821+
816822
\`\`\`esql
817823
ROW a = 10, b = 20
818824
| EVAL g = GREATEST(a, b)
819825
\`\`\`
820-
Note: When run on \`keyword\` or \`text\` fields, this returns the last string in alphabetical order. When run on \`boolean\` columns this will return \`true\` if any values are \`true\`.
821826
`,
822827
description:
823828
'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)',
@@ -1026,13 +1031,14 @@ export const functions = {
10261031
### LENGTH
10271032
Returns the character length of a string.
10281033
1034+
Note: All strings are in UTF-8, so a single character can use multiple bytes.
1035+
10291036
\`\`\`esql
10301037
FROM airports
10311038
| WHERE country == "India"
10321039
| KEEP city
10331040
| EVAL fn_length = LENGTH(city)
10341041
\`\`\`
1035-
Note: All strings are in UTF-8, so a single character can use multiple bytes.
10361042
`,
10371043
description:
10381044
'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)',
@@ -1447,11 +1453,12 @@ export const functions = {
14471453
### MV DEDUPE
14481454
Remove duplicate values from a multivalued field.
14491455
1456+
Note: \`MV_DEDUPE\` may, but won’t always, sort the values in the column.
1457+
14501458
\`\`\`esql
14511459
ROW a=["foo", "foo", "bar", "foo"]
14521460
| EVAL dedupe_a = MV_DEDUPE(a)
14531461
\`\`\`
1454-
Note: \`MV_DEDUPE\` may, but won’t always, sort the values in the column.
14551462
`,
14561463
description:
14571464
'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)',
@@ -1612,11 +1619,12 @@ export const functions = {
16121619
16131620
It is calculated as the median of each data point’s deviation from the median of the entire sample. That is, for a random variable \`X\`, the median absolute deviation is \`median(|median(X) - X|)\`.
16141621
1622+
Note: If the field has an even number of values, the medians will be calculated as the average of the middle two values. If the value is not a floating point number, the averages are rounded towards 0.
1623+
16151624
\`\`\`esql
16161625
ROW values = [0, 2, 5, 6]
16171626
| EVAL median_absolute_deviation = MV_MEDIAN_ABSOLUTE_DEVIATION(values), median = MV_MEDIAN(values)
16181627
\`\`\`
1619-
Note: If the field has an even number of values, the medians will be calculated as the average of the middle two values. If the value is not a floating point number, the averages are rounded towards 0.
16201628
`,
16211629
description:
16221630
'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)',
@@ -1917,11 +1925,12 @@ export const functions = {
19171925
### POW
19181926
Returns the value of \`base\` raised to the power of \`exponent\`.
19191927
1928+
Note: It is still possible to overflow a double result here; in that case, null will be returned.
1929+
19201930
\`\`\`esql
19211931
ROW base = 2.0, exponent = 2
19221932
| EVAL result = POW(base, exponent)
19231933
\`\`\`
1924-
Note: It is still possible to overflow a double result here; in that case, null will be returned.
19251934
`,
19261935
description:
19271936
'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)',
@@ -3198,13 +3207,14 @@ export const functions = {
31983207
### TO DATE NANOS
31993208
Converts an input to a nanosecond-resolution date value (aka date_nanos).
32003209
3210+
Note: The range for date nanos is 1970-01-01T00:00:00.000000000Z to 2262-04-11T23:47:16.854775807Z, attempting to convert values outside of that range will result in null with a warning. Additionally, integers cannot be converted into date nanos, as the range of integer nanoseconds only covers about 2 seconds after epoch.
3211+
32013212
\`\`\`esql
32023213
FROM date_nanos
32033214
| WHERE MV_MIN(nanos) < TO_DATE_NANOS("2023-10-23T12:27:28.948Z")
32043215
AND millis > "2000-01-01"
32053216
| SORT nanos DESC
32063217
\`\`\`
3207-
Note: The range for date nanos is 1970-01-01T00:00:00.000000000Z to 2262-04-11T23:47:16.854775807Z, attempting to convert values outside of that range will result in null with a warning. Additionally, integers cannot be converted into date nanos, as the range of integer nanoseconds only covers about 2 seconds after epoch.
32083218
`,
32093219
description:
32103220
'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)',
@@ -3265,11 +3275,12 @@ export const functions = {
32653275
A string will only be successfully converted if it’s respecting the format \`yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\`.
32663276
To convert dates in other formats, use [\`DATE_PARSE\`](https://www.elastic.co/docs/reference/query-languages/esql/functions-operators/date-time-functions#esql-date_parse).
32673277
3278+
Note: Note that when converting from nanosecond resolution to millisecond resolution with this function, the nanosecond date is truncated, not rounded.
3279+
32683280
\`\`\`esql
32693281
ROW string = ["1953-09-02T00:00:00.000Z", "1964-06-02T00:00:00.000Z", "1964-06-02 00:00:00"]
32703282
| EVAL datetime = TO_DATETIME(string)
32713283
\`\`\`
3272-
Note: Note that when converting from nanosecond resolution to millisecond resolution with this function, the nanosecond date is truncated, not rounded.
32733284
`,
32743285
description:
32753286
'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)',

src/platform/packages/shared/kbn-esql-validation-autocomplete/src/definitions/generated/function_names.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export const esqlFunctionNames = [
5656
'E',
5757
'ENDS_WITH',
5858
'EXP',
59+
'FIRST_OVER_TIME',
5960
'FLOOR',
6061
'FROM_BASE64',
6162
'GREATEST',
@@ -64,6 +65,7 @@ export const esqlFunctionNames = [
6465
'IP_PREFIX',
6566
'KNN',
6667
'KQL',
68+
'LAST_OVER_TIME',
6769
'LEAST',
6870
'LEFT',
6971
'LENGTH',
@@ -103,6 +105,7 @@ export const esqlFunctionNames = [
103105
'PI',
104106
'POW',
105107
'QSTR',
108+
'RATE',
106109
'REPEAT',
107110
'REPLACE',
108111
'REVERSE',
@@ -197,7 +200,6 @@ export const esqlFunctionNames = [
197200
'NOT_LIKE',
198201
'NOT_RLIKE',
199202
'NOT_EQUALS',
200-
'PREDICATES',
201203
'RLIKE',
202204
'SUB',
203205
];

src/platform/packages/shared/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2256,7 +2256,7 @@ const isNotNullDefinition: FunctionDefinition = {
22562256
Location.COMPLETION,
22572257
],
22582258
validate: undefined,
2259-
examples: [],
2259+
examples: ['FROM employees\n| WHERE is_rehired IS NOT NULL\n| STATS COUNT(emp_no)'],
22602260
};
22612261

22622262
// Do not edit this manually... generated by scripts/generate_function_definitions.ts
@@ -2459,7 +2459,7 @@ const isNullDefinition: FunctionDefinition = {
24592459
Location.COMPLETION,
24602460
],
24612461
validate: undefined,
2462-
examples: [],
2462+
examples: ['FROM employees\n| WHERE birth_date IS NULL'],
24632463
};
24642464

24652465
// Do not edit this manually... generated by scripts/generate_function_definitions.ts
@@ -3235,7 +3235,7 @@ const likeDefinition: FunctionDefinition = {
32353235
name: 'like',
32363236
description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.like', {
32373237
defaultMessage:
3238-
'Use `LIKE` to filter data based on string patterns using wildcards. `LIKE`\nusually acts on a field placed on the left-hand side of the operator, but it can\nalso act on a constant (literal) expression. The right-hand side of the operator\nrepresents the pattern or a list of patterns. If a list of patterns is provided,\nthe expression will return true if any of the patterns match.\n\nThe following wildcard characters are supported:\n\n* `*` matches zero or more characters.\n* `?` matches one character.',
3238+
'Use `LIKE` to filter data based on string patterns using wildcards. `LIKE`\nusually acts on a field placed on the left-hand side of the operator, but it can\nalso act on a constant (literal) expression. The right-hand side of the operator\nrepresents the pattern.\n\nThe following wildcard characters are supported:\n\n* `*` matches zero or more characters.\n* `?` matches one character.',
32393239
}),
32403240
preview: false,
32413241
alias: undefined,
@@ -4492,7 +4492,7 @@ const notLikeDefinition: FunctionDefinition = {
44924492
name: 'not like',
44934493
description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.not_like', {
44944494
defaultMessage:
4495-
'Use `LIKE` to filter data based on string patterns using wildcards. `LIKE`\nusually acts on a field placed on the left-hand side of the operator, but it can\nalso act on a constant (literal) expression. The right-hand side of the operator\nrepresents the pattern or a list of patterns. If a list of patterns is provided,\nthe expression will return true if any of the patterns match.\n\nThe following wildcard characters are supported:\n\n* `*` matches zero or more characters.\n* `?` matches one character.',
4495+
'Use `LIKE` to filter data based on string patterns using wildcards. `LIKE`\nusually acts on a field placed on the left-hand side of the operator, but it can\nalso act on a constant (literal) expression. The right-hand side of the operator\nrepresents the pattern.\n\nThe following wildcard characters are supported:\n\n* `*` matches zero or more characters.\n* `?` matches one character.',
44964496
}),
44974497
preview: false,
44984498
alias: undefined,

src/platform/packages/shared/kbn-esql-validation-autocomplete/src/definitions/generated/scalar_functions.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2966,8 +2966,7 @@ const knnDefinition: FunctionDefinition = {
29662966
],
29672967
validate: undefined,
29682968
examples: [
2969-
'from colors metadata _score\n| where knn(rgb_vector, [0, 120, 0])\n| sort _score desc, color asc',
2970-
'from colors metadata _score\n| where knn(rgb_vector, [0,255,255], {"k": 4})\n| sort _score desc, color asc',
2969+
'from colors metadata _score\n| where knn(rgb_vector, [0, 120, 0], 10)\n| sort _score desc, color asc',
29712970
],
29722971
};
29732972

0 commit comments

Comments
 (0)