From ad916685fc2fb8581678043efd330a679a0a8f06 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Mon, 21 Oct 2024 19:44:31 +1100 Subject: [PATCH] [ES|QL] Update function metadata (#196993) This PR updates the function definitions and inline docs based on the latest metadata from Elasticsearch. --------- Co-authored-by: Stratoula Kalafateli --- .../autocomplete.suggest.eval.test.ts | 4 +- .../definitions/generated/scalar_functions.ts | 82 ++++++++++++++++++- .../sections/generated/scalar_functions.tsx | 69 ++++++++++++++++ 3 files changed, 151 insertions(+), 4 deletions(-) diff --git a/packages/kbn-esql-validation-autocomplete/src/autocomplete/__tests__/autocomplete.suggest.eval.test.ts b/packages/kbn-esql-validation-autocomplete/src/autocomplete/__tests__/autocomplete.suggest.eval.test.ts index cc04ccb407e6e..dcb6fe76f184b 100644 --- a/packages/kbn-esql-validation-autocomplete/src/autocomplete/__tests__/autocomplete.suggest.eval.test.ts +++ b/packages/kbn-esql-validation-autocomplete/src/autocomplete/__tests__/autocomplete.suggest.eval.test.ts @@ -363,8 +363,8 @@ describe('autocomplete.suggest', () => { // // Test suggestions for each possible param, within each signature variation, for each function for (const fn of scalarFunctionDefinitions) { // skip this fn for the moment as it's quite hard to test - // if (!['bucket', 'date_extract', 'date_diff', 'case'].includes(fn.name)) { - if (!['bucket', 'date_extract', 'date_diff', 'case'].includes(fn.name)) { + // Add match in the text when the autocomplete is ready https://github.com/elastic/kibana/issues/196995 + if (!['bucket', 'date_extract', 'date_diff', 'case', 'match'].includes(fn.name)) { test(`${fn.name}`, async () => { const testedCases = new Set(); diff --git a/packages/kbn-esql-validation-autocomplete/src/definitions/generated/scalar_functions.ts b/packages/kbn-esql-validation-autocomplete/src/definitions/generated/scalar_functions.ts index ea5f8f86e1909..2ace3e9ddc537 100644 --- a/packages/kbn-esql-validation-autocomplete/src/definitions/generated/scalar_functions.ts +++ b/packages/kbn-esql-validation-autocomplete/src/definitions/generated/scalar_functions.ts @@ -3209,6 +3209,85 @@ const ltrimDefinition: FunctionDefinition = { ], }; +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const matchDefinition: FunctionDefinition = { + type: 'eval', + name: 'match', + description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.match', { + defaultMessage: + 'Performs a match query on the specified field. Returns true if the provided query matches the row.', + }), + alias: undefined, + signatures: [ + { + params: [ + { + name: 'field', + type: 'keyword', + optional: false, + }, + { + name: 'query', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'field', + type: 'keyword', + optional: false, + }, + { + name: 'query', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'field', + type: 'text', + optional: false, + }, + { + name: 'query', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'field', + type: 'text', + optional: false, + }, + { + name: 'query', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'], + supportedOptions: ['by'], + validate: undefined, + examples: [ + 'from books \n| where match(author, "Faulkner")\n| keep book_no, author \n| sort book_no \n| limit 5;', + ], +}; + // Do not edit this manually... generated by scripts/generate_function_definitions.ts const mvAppendDefinition: FunctionDefinition = { type: 'eval', @@ -5770,8 +5849,6 @@ const qstrDefinition: FunctionDefinition = { defaultMessage: 'Performs a query string query. Returns true if the provided query string matches the row.', }), - ignoreAsSuggestion: true, - alias: undefined, signatures: [ { @@ -9077,6 +9154,7 @@ export const scalarFunctionDefinitions = [ logDefinition, log10Definition, ltrimDefinition, + matchDefinition, mvAppendDefinition, mvAvgDefinition, mvConcatDefinition, diff --git a/packages/kbn-language-documentation/src/sections/generated/scalar_functions.tsx b/packages/kbn-language-documentation/src/sections/generated/scalar_functions.tsx index 3b74c73cd2a9a..32e66931cedcd 100644 --- a/packages/kbn-language-documentation/src/sections/generated/scalar_functions.tsx +++ b/packages/kbn-language-documentation/src/sections/generated/scalar_functions.tsx @@ -1139,6 +1139,42 @@ export const functions = { | EVAL message = CONCAT("'", message, "'") | EVAL color = CONCAT("'", color, "'") \`\`\` + `, + description: + 'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)', + ignoreTag: true, + } + )} + /> + ), + }, + // Do not edit manually... automatically generated by scripts/generate_esql_docs.ts + { + label: i18n.translate('languageDocumentation.documentationESQL.match', { + defaultMessage: 'MATCH', + }), + description: ( + + + ### MATCH + Performs a match query on the specified field. Returns true if the provided query matches the row. + + \`\`\` + from books + | where match(author, "Faulkner") + | keep book_no, author + | sort book_no + | limit 5; + \`\`\` `, description: 'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)', @@ -1801,6 +1837,39 @@ export const functions = { | EVAL result = POW(base, exponent) \`\`\` Note: It is still possible to overflow a double result here; in that case, null will be returned. + `, + description: + 'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)', + ignoreTag: true, + })} + /> + ), + }, + // Do not edit manually... automatically generated by scripts/generate_esql_docs.ts + { + label: i18n.translate('languageDocumentation.documentationESQL.qstr', { + defaultMessage: 'QSTR', + }), + description: ( + + + ### QSTR + Performs a query string query. Returns true if the provided query string matches the row. + + \`\`\` + from books + | where qstr("author: Faulkner") + | keep book_no, author + | sort book_no + | limit 5; + \`\`\` `, description: 'Text is in markdown. Do not translate function names, special characters, or field names like sum(bytes)',