diff --git a/src/platform/packages/shared/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts b/src/platform/packages/shared/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts index 3a810cac3ad75..4adf2ffa24f31 100644 --- a/src/platform/packages/shared/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts +++ b/src/platform/packages/shared/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts @@ -12,7 +12,7 @@ import { writeFile } from 'fs/promises'; import { join } from 'path'; import _ from 'lodash'; import type { RecursivePartial } from '@kbn/utility-types'; -import { FunctionDefinition } from '../src/definitions/types'; +import { FunctionDefinition, FunctionParameterType, Signature } from '../src/definitions/types'; import { FULL_TEXT_SEARCH_FUNCTIONS } from '../src/shared/constants'; const aliasTable: Record = { to_version: ['to_ver'], @@ -264,6 +264,7 @@ function getFunctionDefinition(ESFunctionDefinition: Record): Funct const ret = { type: ESFunctionDefinition.type, name: ESFunctionDefinition.name, + operator: ESFunctionDefinition.operator, ...supportedCommandsAndOptions, description: ESFunctionDefinition.description, alias: aliasTable[ESFunctionDefinition.name], @@ -276,9 +277,11 @@ function getFunctionDefinition(ESFunctionDefinition: Record): Funct ...param, type: convertDateTime(param.type), description: undefined, - ...(idx === 0 && FULL_TEXT_SEARCH_FUNCTIONS.includes(ESFunctionDefinition.name) + ...(FULL_TEXT_SEARCH_FUNCTIONS.includes(ESFunctionDefinition.name) ? // Default to false. If set to true, this parameter does not accept a function or literal, only fields. - { fieldsOnly: true } + idx === 0 + ? { fieldsOnly: true } + : { constantOnly: true } : {}), })), returnType: convertDateTime(signature.returnType), @@ -299,9 +302,391 @@ function getFunctionDefinition(ESFunctionDefinition: Record): Funct return ret as FunctionDefinition; } +const comparisonOperatorSignatures = (['ip', 'version'] as const).flatMap((type) => [ + { + params: [ + { name: 'left', type }, + { name: 'right', type: 'text' as const, constantOnly: true }, + ], + returnType: 'boolean' as const, + }, + { + params: [ + { name: 'left', type: 'text' as const, constantOnly: true }, + { name: 'right', type }, + ], + returnType: 'boolean' as const, + }, +]); +const operatorsMeta: Record< + string, + { + name: string; + isMathOperator: boolean; + isComparisonOperator: boolean; + extraSignatures?: Signature[]; + } +> = { + add: { + name: '+', + isMathOperator: true, + isComparisonOperator: false, + extraSignatures: [ + { + params: [ + { name: 'left', type: 'time_literal' as const }, + { name: 'right', type: 'date' as const }, + ], + returnType: 'date' as const, + }, + { + params: [ + { name: 'left', type: 'date' as const }, + { name: 'right', type: 'time_literal' as const }, + ], + returnType: 'date' as const, + }, + ], + }, + sub: { + name: '-', + isMathOperator: true, + isComparisonOperator: false, + extraSignatures: [ + { + params: [ + { name: 'left', type: 'time_literal' as const }, + { name: 'right', type: 'date' as const }, + ], + returnType: 'date' as const, + }, + { + params: [ + { name: 'left', type: 'date' as const }, + { name: 'right', type: 'time_literal' as const }, + ], + returnType: 'date' as const, + }, + ], + }, + div: { name: '/', isMathOperator: true, isComparisonOperator: false }, + equals: { + name: '==', + isMathOperator: false, + isComparisonOperator: true, + extraSignatures: [ + ...comparisonOperatorSignatures, + { + params: [ + { name: 'left', type: 'boolean' as const }, + { name: 'right', type: 'boolean' as const }, + ], + returnType: 'boolean' as const, + }, + // constant strings okay because of implicit casting + { + params: [ + { name: 'left', type: 'boolean' as const }, + { name: 'right', type: 'keyword' as const, constantOnly: true }, + ], + returnType: 'boolean' as const, + }, + { + params: [ + { name: 'left', type: 'keyword' as const, constantOnly: true }, + { name: 'right', type: 'boolean' as const }, + ], + returnType: 'boolean' as const, + }, + ], + }, + greater_than: { + name: '>', + isMathOperator: false, + isComparisonOperator: true, + extraSignatures: comparisonOperatorSignatures, + }, + greater_than_or_equal: { + name: '>=', + isMathOperator: false, + isComparisonOperator: true, + extraSignatures: comparisonOperatorSignatures, + }, + less_than: { + name: '<', + isMathOperator: false, + isComparisonOperator: true, + extraSignatures: comparisonOperatorSignatures, + }, + less_than_or_equal: { name: '<=', isMathOperator: false, isComparisonOperator: true }, + not_equals: { + name: '!=', + isMathOperator: false, + isComparisonOperator: true, + extraSignatures: [ + ...comparisonOperatorSignatures, + { + params: [ + { name: 'left', type: 'boolean' as const }, + { name: 'right', type: 'boolean' as const }, + ], + returnType: 'boolean' as const, + }, + // constant strings okay because of implicit casting + { + params: [ + { name: 'left', type: 'boolean' as const }, + { name: 'right', type: 'keyword' as const, constantOnly: true }, + ], + returnType: 'boolean' as const, + }, + { + params: [ + { name: 'left', type: 'keyword' as const, constantOnly: true }, + { name: 'right', type: 'boolean' as const }, + ], + returnType: 'boolean' as const, + }, + ], + }, + mod: { name: '%', isMathOperator: true, isComparisonOperator: false }, + mul: { name: '*', isMathOperator: true, isComparisonOperator: false }, + like: { + name: 'like', + isMathOperator: false, + isComparisonOperator: false, + extraSignatures: [ + { + params: [ + { + name: 'str', + type: 'text', + optional: false, + }, + { + name: 'pattern', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'str', + type: 'keyword', + optional: false, + }, + { + name: 'pattern', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + ], + }, + + rlike: { + name: 'rlike', + isMathOperator: false, + isComparisonOperator: false, + extraSignatures: [ + { + params: [ + { + name: 'str', + type: 'text', + optional: false, + }, + { + name: 'pattern', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'str', + type: 'keyword', + optional: false, + }, + { + name: 'pattern', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + ], + }, +}; + +const validators: Record = { + div: `(fnDef) => { + const [left, right] = fnDef.args; + const messages = []; + if (!Array.isArray(left) && !Array.isArray(right)) { + if (right.type === 'literal' && isNumericType(right.literalType)) { + if (right.value === 0) { + messages.push({ + type: 'warning' as const, + code: 'divideByZero', + text: i18n.translate( + 'kbn-esql-validation-autocomplete.esql.divide.warning.divideByZero', + { + defaultMessage: 'Cannot divide by zero: {left}/{right}', + values: { + left: left.text, + right: right.value, + }, + } + ), + location: fnDef.location, + }); + } + } + } + return messages; + }`, + mod: `(fnDef) => { + const [left, right] = fnDef.args; + const messages = []; + if (!Array.isArray(left) && !Array.isArray(right)) { + if (right.type === 'literal' && isNumericType(right.literalType)) { + if (right.value === 0) { + messages.push({ + type: 'warning' as const, + code: 'moduleByZero', + text: i18n.translate( + 'kbn-esql-validation-autocomplete.esql.divide.warning.zeroModule', + { + defaultMessage: 'Module by zero can return null value: {left}%{right}', + values: { + left: left.text, + right: right.value, + }, + } + ), + location: fnDef.location, + }); + } + } + } + return messages; + }`, +}; + +/** + * Elasticsearch doc exports name as 'lhs' or 'rhs' instead of 'left' or 'right' + * @param str + * @returns + */ +const replaceParamName = (str: string) => { + switch (str) { + case 'lhs': + return 'left'; + case 'rhs': + return 'right'; + + // @todo: For in function where Kibana doesn't interpret field and inlist + case 'field': + return 'left'; + case 'inlist': + return 'right'; + default: + return str; + } +}; + +const enrichOperators = ( + operatorsFunctionDefinitions: FunctionDefinition[] +): FunctionDefinition[] => { + // @ts-expect-error Stringified version of the validator function + return operatorsFunctionDefinitions.map((op) => { + const isMathOperator = + Object.hasOwn(operatorsMeta, op.name) && operatorsMeta[op.name]?.isMathOperator; + const isComparisonOperator = + Object.hasOwn(operatorsMeta, op.name) && operatorsMeta[op.name]?.isComparisonOperator; + + const isInOperator = op.name === 'in' || op.name === 'not_in'; + const isLikeOperator = /like/i.test(op.name); + const isNotOperator = + op.name?.toLowerCase()?.startsWith('not_') && (isInOperator || isInOperator); + + let signatures = op.signatures.map((s) => ({ + ...s, + // Elasticsearch docs uses lhs and rhs instead of left and right that Kibana code uses + params: s.params.map((param) => ({ ...param, name: replaceParamName(param.name) })), + })); + let supportedCommands = op.supportedCommands; + let supportedOptions = op.supportedOptions; + if (isComparisonOperator) { + supportedCommands = _.uniq([...op.supportedCommands, 'eval', 'where', 'row', 'sort']); + supportedOptions = ['by']; + } + if (isMathOperator) { + supportedCommands = _.uniq([ + ...op.supportedCommands, + 'eval', + 'where', + 'row', + 'stats', + 'metrics', + 'sort', + ]); + supportedOptions = ['by']; + } + if (isInOperator || isLikeOperator || isNotOperator) { + supportedCommands = ['eval', 'where', 'row', 'sort']; + } + if (isInOperator) { + // Override the signatures to be array types instead of singular + // i.e. right: 'keyword' -> right: 'keyword[]' + // so that in would open up ($0) + signatures = signatures.map((s) => ({ + ...s, + params: s.params.map((p, idx) => ({ + ...p, + type: `${p.type}${idx === 1 ? '[]' : ''}` as FunctionParameterType, + })), + })); + } + if ( + Object.hasOwn(operatorsMeta, op.name) && + Array.isArray(operatorsMeta[op.name]?.extraSignatures) + ) { + signatures.push(...(operatorsMeta[op.name].extraSignatures ?? [])); + } + + return { + ...op, + signatures, + // Elasticsearch docs does not include the full supported commands for math operators + // so we are overriding to add proper support + supportedCommands, + supportedOptions, + // @TODO: change to operator type + type: 'builtin' as const, + validate: validators[op.name], + ...(isNotOperator ? { ignoreAsSuggestion: true } : {}), + }; + }); +}; + function printGeneratedFunctionsFile( functionDefinitions: FunctionDefinition[], - functionsType: 'aggregation' | 'scalar' + functionsType: 'aggregation' | 'scalar' | 'operators' ) { /** * Deals with asciidoc internal cross-references in the function descriptions @@ -343,12 +728,19 @@ function printGeneratedFunctionsFile( functionDefinition: FunctionDefinition, functionNames: string[] ) => { - const { type, name, description, alias, signatures } = functionDefinition; + const { type, name, description, alias, signatures, operator } = functionDefinition; + let functionName = operator?.toLowerCase() ?? name.toLowerCase(); + if (functionName.includes('not')) { + functionName = name; + } + if (name.toLowerCase() === 'match') { + functionName = 'match'; + } return `// Do not edit this manually... generated by scripts/generate_function_definitions.ts const ${getDefinitionName(name)}: FunctionDefinition = { type: '${type}', - name: '${name}', + name: '${functionName}', description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.${name}', { defaultMessage: ${JSON.stringify( removeAsciiDocInternalCrossReferences(removeInlineAsciiDocLinks(description), functionNames) )} }),${functionDefinition.ignoreAsSuggestion ? 'ignoreAsSuggestion: true,\n' : ''} @@ -389,6 +781,8 @@ ${ import { isLiteralItem } from '../../shared/helpers';` : '' } +${functionsType === 'operators' ? `import { isNumericType } from '../../shared/esql_types';` : ''} + `; @@ -428,14 +822,24 @@ import { isLiteralItem } from '../../shared/helpers';` const scalarFunctionDefinitions: FunctionDefinition[] = []; const aggFunctionDefinitions: FunctionDefinition[] = []; + const operatorDefinitions: FunctionDefinition[] = []; + for (const ESDefinition of ESFunctionDefinitions) { if (aliases.has(ESDefinition.name) || excludedFunctions.has(ESDefinition.name)) { continue; } const functionDefinition = getFunctionDefinition(ESDefinition); + const isLikeOperator = functionDefinition.name.toLowerCase().includes('like'); - if (functionDefinition.type === 'eval') { + if (functionDefinition.name.toLowerCase() === 'match') { + scalarFunctionDefinitions.push({ ...functionDefinition, type: 'eval' }); + continue; + } + if (functionDefinition.type === 'operator' || isLikeOperator) { + operatorDefinitions.push(functionDefinition); + } + if (functionDefinition.type === 'eval' && !isLikeOperator) { scalarFunctionDefinitions.push(functionDefinition); } else if (functionDefinition.type === 'agg') { aggFunctionDefinitions.push(functionDefinition); @@ -452,4 +856,8 @@ import { isLiteralItem } from '../../shared/helpers';` join(__dirname, '../src/definitions/generated/aggregation_functions.ts'), printGeneratedFunctionsFile(aggFunctionDefinitions, 'aggregation') ); + await writeFile( + join(__dirname, '../src/definitions/generated/operators.ts'), + printGeneratedFunctionsFile(enrichOperators(operatorDefinitions), 'operators') + ); })(); diff --git a/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/autocomplete/__tests__/autocomplete.command.where.test.ts b/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/autocomplete/__tests__/autocomplete.command.where.test.ts index 30a6b0b9498db..c48fb63383c7f 100644 --- a/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/autocomplete/__tests__/autocomplete.command.where.test.ts +++ b/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/autocomplete/__tests__/autocomplete.command.where.test.ts @@ -74,8 +74,8 @@ describe('WHERE ', () => { const expectedComparisonWithDateSuggestions = [ ...getDateLiterals(), ...getFieldNamesByType(['date']), - // all functions compatible with a keywordField type - ...getFunctionSignaturesByReturnType('where', ['date'], { scalar: true }), + ...getFieldNamesByType(['date_nanos']), + ...getFunctionSignaturesByReturnType('where', ['date', 'date_nanos'], { scalar: true }), ]; await assertSuggestions( 'from a | where dateField == /', @@ -213,10 +213,18 @@ describe('WHERE ', () => { ]); await assertSuggestions('from index | WHERE not /', [ ...getFieldNamesByType('boolean').map((name) => attachTriggerCommand(`${name} `)), - ...getFunctionSignaturesByReturnType('where', 'boolean', { scalar: true }), + ...getFunctionSignaturesByReturnType('where', 'boolean', { scalar: true }, undefined, [ + ':', + ]), ]); await assertSuggestions('FROM index | WHERE NOT ENDS_WITH(keywordField, "foo") /', [ - ...getFunctionSignaturesByReturnType('where', 'boolean', { builtin: true }, ['boolean']), + ...getFunctionSignaturesByReturnType( + 'where', + 'boolean', + { builtin: true }, + ['boolean'], + [':'] + ), pipeCompleteItem, ]); await assertSuggestions('from index | WHERE keywordField IS NOT/', [ @@ -291,9 +299,13 @@ describe('WHERE ', () => { const { assertSuggestions } = await setup(); await assertSuggestions('FROM index | WHERE doubleField + doubleField /', [ - ...getFunctionSignaturesByReturnType('where', 'any', { builtin: true, skipAssign: true }, [ - 'double', - ]), + ...getFunctionSignaturesByReturnType( + 'where', + 'any', + { builtin: true, skipAssign: true }, + ['double'], + [':'] + ), ]); }); diff --git a/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/autocomplete/autocomplete.ts b/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/autocomplete/autocomplete.ts index 596efa7fb8677..454c0b135ae6f 100644 --- a/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/autocomplete/autocomplete.ts +++ b/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/autocomplete/autocomplete.ts @@ -81,7 +81,7 @@ import { getOperatorSuggestions, getSuggestionsAfterNot, } from './factories'; -import { EDITOR_MARKER, METADATA_FIELDS } from '../shared/constants'; +import { EDITOR_MARKER, FULL_TEXT_SEARCH_FUNCTIONS, METADATA_FIELDS } from '../shared/constants'; import { getAstContext, removeMarkerArgFromArgsList } from '../shared/context'; import { buildQueryUntilPreviousCommand, @@ -1229,10 +1229,12 @@ async function getFunctionArgsSuggestions( })) ); } + // could also be in stats (bucket) but our autocomplete is not great yet if ( (getTypesFromParamDefs(typesToSuggestNext).includes('date') && - ['where', 'eval'].includes(command.name)) || + ['where', 'eval'].includes(command.name) && + !FULL_TEXT_SEARCH_FUNCTIONS.includes(fnDefinition.name)) || (command.name === 'stats' && typesToSuggestNext.some((t) => t && t.type === 'date' && t.constantOnly === true)) ) diff --git a/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/autocomplete/commands/where/index.ts b/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/autocomplete/commands/where/index.ts index a7d381538f738..ef915b19d1a90 100644 --- a/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/autocomplete/commands/where/index.ts +++ b/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/autocomplete/commands/where/index.ts @@ -29,6 +29,7 @@ import { getOverlapRange, getSuggestionsToRightOfOperatorExpression } from '../. import { getPosition } from './util'; import { pipeCompleteItem } from '../../complete_items'; import { + EDITOR_MARKER, UNSUPPORTED_COMMANDS_BEFORE_MATCH, UNSUPPORTED_COMMANDS_BEFORE_QSTR, } from '../../../shared/constants'; @@ -169,12 +170,14 @@ export async function suggest( if (priorCommands.some((c) => UNSUPPORTED_COMMANDS_BEFORE_QSTR.has(c))) { ignored.push('qstr'); } - - const columnSuggestions = await getColumnsByType('any', [], { - advanceCursor: true, - openSuggestions: true, - }); - + const last = fullTextAst?.[fullTextAst.length - 1]; + let columnSuggestions: SuggestionRawDefinition[] = []; + if (!last?.text?.endsWith(`:${EDITOR_MARKER}`)) { + columnSuggestions = await getColumnsByType('any', [], { + advanceCursor: true, + openSuggestions: true, + }); + } suggestions.push( ...columnSuggestions, ...getFunctionSuggestions({ command: 'where', ignored }) diff --git a/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/autocomplete/helper.ts b/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/autocomplete/helper.ts index 716d3d8bb3250..f3acaddfc076b 100644 --- a/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/autocomplete/helper.ts +++ b/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/autocomplete/helper.ts @@ -575,7 +575,7 @@ export async function getSuggestionsToRightOfOperatorExpression({ operatorReturnType === 'unknown' || operatorReturnType === 'unsupported' ? 'any' : operatorReturnType, - ignored: ['='], + ignored: ['=', ':'], }) ); } else { diff --git a/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/definitions/builtin.ts b/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/definitions/builtin.ts index 9a289c196e558..eacad51ee7b59 100644 --- a/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/definitions/builtin.ts +++ b/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/definitions/builtin.ts @@ -8,9 +8,9 @@ */ import { i18n } from '@kbn/i18n'; -import { ESQL_NUMBER_TYPES, isNumericType } from '../shared/esql_types'; +import { isNumericType } from '../shared/esql_types'; import type { FunctionDefinition, FunctionParameterType, FunctionReturnType } from './types'; - +import { operatorsFunctionDefinitions } from './generated/operators'; type MathFunctionSignature = [FunctionParameterType, FunctionParameterType, FunctionReturnType]; function createMathDefinition( @@ -384,150 +384,6 @@ export const comparisonFunctions: FunctionDefinition[] = [ }, ].map((op): FunctionDefinition => createComparisonDefinition(op)); -const likeFunctions: FunctionDefinition[] = [ - // Skip the insensitive case equality until it gets restored back - // new special comparison operator for strings only - // { - // name: '=~', - // description: i18n.translate('kbn-esql-validation-autocomplete.esql.definition.equalToCaseInsensitiveDoc', { - // defaultMessage: 'Case insensitive equality', - // }), - // }, - { - name: 'like', - description: i18n.translate('kbn-esql-validation-autocomplete.esql.definition.likeDoc', { - defaultMessage: 'Filter data based on string patterns', - }), - }, - { name: 'not_like', description: '' }, - { - name: 'rlike', - description: i18n.translate('kbn-esql-validation-autocomplete.esql.definition.rlikeDoc', { - defaultMessage: 'Filter data based on string regular expressions', - }), - }, - { name: 'not_rlike', description: '' }, -].map(({ name, description }) => { - const def: FunctionDefinition = { - type: 'builtin' as const, - ignoreAsSuggestion: /not/.test(name), - name, - description, - supportedCommands: ['eval', 'where', 'row', 'sort'], - supportedOptions: ['by'], - signatures: [ - { - params: [ - { name: 'left', type: 'text' as const }, - { name: 'right', type: 'text' as const }, - ], - returnType: 'boolean', - }, - { - params: [ - { name: 'left', type: 'text' as const }, - { name: 'right', type: 'keyword' as const }, - ], - returnType: 'boolean', - }, - { - params: [ - { name: 'left', type: 'keyword' as const }, - { name: 'right', type: 'text' as const }, - ], - returnType: 'boolean', - }, - { - params: [ - { name: 'left', type: 'keyword' as const }, - { name: 'right', type: 'keyword' as const }, - ], - returnType: 'boolean', - }, - ], - }; - - return def; -}); - -const inFunctions: FunctionDefinition[] = [ - { - name: 'in', - description: i18n.translate('kbn-esql-validation-autocomplete.esql.definition.inDoc', { - defaultMessage: - 'Tests if the value an expression takes is contained in a list of other expressions', - }), - }, - { name: 'not_in', description: '' }, -].map(({ name, description }) => ({ - // set all arrays to type "any" for now - // this only applies to the "in" operator - // e.g. "foo" in ( "foo", "bar" ) - // - // we did this because the "in" operator now supports - // mixed-type arrays like ( "1.2.3", versionVar ) - // because of implicit casting. - // - // we need to revisit with more robust validation - type: 'builtin', - ignoreAsSuggestion: /not/.test(name), - name, - description, - supportedCommands: ['eval', 'where', 'row', 'sort'], - signatures: [ - ...ESQL_NUMBER_TYPES.map((type) => ({ - params: [ - { name: 'left', type: type as FunctionParameterType }, - - { name: 'right', type: 'any[]' as FunctionParameterType }, - ], - returnType: 'boolean' as FunctionReturnType, - })), - { - params: [ - { name: 'left', type: 'keyword' }, - { name: 'right', type: 'any[]' }, - ], - returnType: 'boolean', - }, - { - params: [ - { name: 'left', type: 'text' }, - { name: 'right', type: 'any[]' }, - ], - returnType: 'boolean', - }, - { - params: [ - { name: 'left', type: 'boolean' }, - { name: 'right', type: 'any[]' }, - ], - returnType: 'boolean', - }, - { - params: [ - { name: 'left', type: 'date' }, - { name: 'right', type: 'any[]' }, - ], - returnType: 'boolean', - }, - { - params: [ - { name: 'left', type: 'version' }, - { name: 'right', type: 'any[]' }, - ], - returnType: 'boolean', - }, - { - params: [ - { name: 'left', type: 'ip' }, - { name: 'right', type: 'any[]' }, - ], - returnType: 'boolean', - }, - ], -})); - export const logicalOperators: FunctionDefinition[] = [ { name: 'and', @@ -681,10 +537,7 @@ const otherDefinitions: FunctionDefinition[] = [ ]; export const builtinFunctions: FunctionDefinition[] = [ - ...mathFunctions, - ...comparisonFunctions, - ...likeFunctions, - ...inFunctions, + ...operatorsFunctionDefinitions, ...logicalOperators, ...nullFunctions, ...otherDefinitions, diff --git a/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts b/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts new file mode 100644 index 0000000000000..0e7a276b88147 --- /dev/null +++ b/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts @@ -0,0 +1,5023 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +/** + * __AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.__ + * + * @note This file is generated by the `generate_function_definitions.ts` + * script. Do not edit it manually. + * + * + * + * + * + * + * + * + * + * + * + * + */ + +import { i18n } from '@kbn/i18n'; +import type { FunctionDefinition } from '../types'; + +import { isNumericType } from '../../shared/esql_types'; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const addDefinition: FunctionDefinition = { + type: 'builtin', + name: '+', + description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.add', { + defaultMessage: + 'Add two numbers together. If either field is multivalued then the result is `null`.', + }), + preview: false, + alias: undefined, + signatures: [ + { + params: [ + { + name: 'left', + type: 'date', + optional: false, + }, + { + name: 'right', + type: 'date_period', + optional: false, + }, + ], + returnType: 'date', + }, + { + params: [ + { + name: 'left', + type: 'date', + optional: false, + }, + { + name: 'right', + type: 'time_duration', + optional: false, + }, + ], + returnType: 'date', + }, + { + params: [ + { + name: 'left', + type: 'date_nanos', + optional: false, + }, + { + name: 'right', + type: 'date_period', + optional: false, + }, + ], + returnType: 'date_nanos', + }, + { + params: [ + { + name: 'left', + type: 'date_nanos', + optional: false, + }, + { + name: 'right', + type: 'time_duration', + optional: false, + }, + ], + returnType: 'date_nanos', + }, + { + params: [ + { + name: 'left', + type: 'date_period', + optional: false, + }, + { + name: 'right', + type: 'date', + optional: false, + }, + ], + returnType: 'date', + }, + { + params: [ + { + name: 'left', + type: 'date_period', + optional: false, + }, + { + name: 'right', + type: 'date_nanos', + optional: false, + }, + ], + returnType: 'date_nanos', + }, + { + params: [ + { + name: 'left', + type: 'date_period', + optional: false, + }, + { + name: 'right', + type: 'date_period', + optional: false, + }, + ], + returnType: 'date_period', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'integer', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'left', + type: 'time_duration', + optional: false, + }, + { + name: 'right', + type: 'date', + optional: false, + }, + ], + returnType: 'date', + }, + { + params: [ + { + name: 'left', + type: 'time_duration', + optional: false, + }, + { + name: 'right', + type: 'date_nanos', + optional: false, + }, + ], + returnType: 'date_nanos', + }, + { + params: [ + { + name: 'left', + type: 'time_duration', + optional: false, + }, + { + name: 'right', + type: 'time_duration', + optional: false, + }, + ], + returnType: 'time_duration', + }, + { + params: [ + { + name: 'left', + type: 'unsigned_long', + optional: false, + }, + { + name: 'right', + type: 'unsigned_long', + optional: false, + }, + ], + returnType: 'unsigned_long', + }, + { + params: [ + { + name: 'left', + type: 'time_literal', + }, + { + name: 'right', + type: 'date', + }, + ], + returnType: 'date', + }, + { + params: [ + { + name: 'left', + type: 'date', + }, + { + name: 'right', + type: 'time_literal', + }, + ], + returnType: 'date', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'], + supportedOptions: ['by'], + validate: undefined, + examples: [], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const divDefinition: FunctionDefinition = { + type: 'builtin', + name: '/', + description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.div', { + defaultMessage: + 'Divide one number by another. If either field is multivalued then the result is `null`.', + }), + preview: false, + alias: undefined, + signatures: [ + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'integer', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'left', + type: 'unsigned_long', + optional: false, + }, + { + name: 'right', + type: 'unsigned_long', + optional: false, + }, + ], + returnType: 'unsigned_long', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'], + supportedOptions: ['by'], + validate: (fnDef) => { + const [left, right] = fnDef.args; + const messages = []; + if (!Array.isArray(left) && !Array.isArray(right)) { + if (right.type === 'literal' && isNumericType(right.literalType)) { + if (right.value === 0) { + messages.push({ + type: 'warning' as const, + code: 'divideByZero', + text: i18n.translate( + 'kbn-esql-validation-autocomplete.esql.divide.warning.divideByZero', + { + defaultMessage: 'Cannot divide by zero: {left}/{right}', + values: { + left: left.text, + right: right.value, + }, + } + ), + location: fnDef.location, + }); + } + } + } + return messages; + }, + examples: [], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const equalsDefinition: FunctionDefinition = { + type: 'builtin', + name: '==', + description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.equals', { + defaultMessage: + 'Check if two fields are equal. If either field is multivalued then the result is `null`.', + }), + preview: false, + alias: undefined, + signatures: [ + { + params: [ + { + name: 'left', + type: 'boolean', + optional: false, + }, + { + name: 'right', + type: 'boolean', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'cartesian_point', + optional: false, + }, + { + name: 'right', + type: 'cartesian_point', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'cartesian_shape', + optional: false, + }, + { + name: 'right', + type: 'cartesian_shape', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'date', + optional: false, + }, + { + name: 'right', + type: 'date', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'date', + optional: false, + }, + { + name: 'right', + type: 'date_nanos', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'date_nanos', + optional: false, + }, + { + name: 'right', + type: 'date', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'date_nanos', + optional: false, + }, + { + name: 'right', + type: 'date_nanos', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'geo_point', + optional: false, + }, + { + name: 'right', + type: 'geo_point', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'geo_shape', + optional: false, + }, + { + name: 'right', + type: 'geo_shape', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'ip', + optional: false, + }, + { + name: 'right', + type: 'ip', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'keyword', + optional: false, + }, + { + name: 'right', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'keyword', + optional: false, + }, + { + name: 'right', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'text', + optional: false, + }, + { + name: 'right', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'text', + optional: false, + }, + { + name: 'right', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'unsigned_long', + optional: false, + }, + { + name: 'right', + type: 'unsigned_long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'version', + optional: false, + }, + { + name: 'right', + type: 'version', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'ip', + }, + { + name: 'right', + type: 'text', + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'text', + constantOnly: true, + }, + { + name: 'right', + type: 'ip', + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'version', + }, + { + name: 'right', + type: 'text', + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'text', + constantOnly: true, + }, + { + name: 'right', + type: 'version', + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'boolean', + }, + { + name: 'right', + type: 'boolean', + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'boolean', + }, + { + name: 'right', + type: 'keyword', + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'keyword', + constantOnly: true, + }, + { + name: 'right', + type: 'boolean', + }, + ], + returnType: 'boolean', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'], + supportedOptions: ['by'], + validate: undefined, + examples: [], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const greaterThanDefinition: FunctionDefinition = { + type: 'builtin', + name: '>', + description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.greater_than', { + defaultMessage: + 'Check if one field is greater than another. If either field is multivalued then the result is `null`.', + }), + preview: false, + alias: undefined, + signatures: [ + { + params: [ + { + name: 'left', + type: 'date', + optional: false, + }, + { + name: 'right', + type: 'date', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'date', + optional: false, + }, + { + name: 'right', + type: 'date_nanos', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'date_nanos', + optional: false, + }, + { + name: 'right', + type: 'date', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'date_nanos', + optional: false, + }, + { + name: 'right', + type: 'date_nanos', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'ip', + optional: false, + }, + { + name: 'right', + type: 'ip', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'keyword', + optional: false, + }, + { + name: 'right', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'keyword', + optional: false, + }, + { + name: 'right', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'text', + optional: false, + }, + { + name: 'right', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'text', + optional: false, + }, + { + name: 'right', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'unsigned_long', + optional: false, + }, + { + name: 'right', + type: 'unsigned_long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'version', + optional: false, + }, + { + name: 'right', + type: 'version', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'ip', + }, + { + name: 'right', + type: 'text', + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'text', + constantOnly: true, + }, + { + name: 'right', + type: 'ip', + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'version', + }, + { + name: 'right', + type: 'text', + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'text', + constantOnly: true, + }, + { + name: 'right', + type: 'version', + }, + ], + returnType: 'boolean', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'], + supportedOptions: ['by'], + validate: undefined, + examples: [], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const greaterThanOrEqualDefinition: FunctionDefinition = { + type: 'builtin', + name: '>=', + description: i18n.translate( + 'kbn-esql-validation-autocomplete.esql.definitions.greater_than_or_equal', + { + defaultMessage: + 'Check if one field is greater than or equal to another. If either field is multivalued then the result is `null`.', + } + ), + preview: false, + alias: undefined, + signatures: [ + { + params: [ + { + name: 'left', + type: 'date', + optional: false, + }, + { + name: 'right', + type: 'date', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'date', + optional: false, + }, + { + name: 'right', + type: 'date_nanos', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'date_nanos', + optional: false, + }, + { + name: 'right', + type: 'date', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'date_nanos', + optional: false, + }, + { + name: 'right', + type: 'date_nanos', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'ip', + optional: false, + }, + { + name: 'right', + type: 'ip', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'keyword', + optional: false, + }, + { + name: 'right', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'keyword', + optional: false, + }, + { + name: 'right', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'text', + optional: false, + }, + { + name: 'right', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'text', + optional: false, + }, + { + name: 'right', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'unsigned_long', + optional: false, + }, + { + name: 'right', + type: 'unsigned_long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'version', + optional: false, + }, + { + name: 'right', + type: 'version', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'ip', + }, + { + name: 'right', + type: 'text', + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'text', + constantOnly: true, + }, + { + name: 'right', + type: 'ip', + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'version', + }, + { + name: 'right', + type: 'text', + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'text', + constantOnly: true, + }, + { + name: 'right', + type: 'version', + }, + ], + returnType: 'boolean', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'], + supportedOptions: ['by'], + validate: undefined, + examples: [], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const inDefinition: FunctionDefinition = { + type: 'builtin', + name: 'in', + description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.in', { + defaultMessage: + 'The `IN` operator allows testing whether a field or expression equals an element in a list of literals, fields or expressions.', + }), + preview: false, + alias: undefined, + signatures: [ + { + params: [ + { + name: 'left', + type: 'boolean', + optional: false, + }, + { + name: 'right', + type: 'boolean[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'left', + type: 'cartesian_point', + optional: false, + }, + { + name: 'right', + type: 'cartesian_point[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'left', + type: 'cartesian_shape', + optional: false, + }, + { + name: 'right', + type: 'cartesian_shape[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'double[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'left', + type: 'geo_point', + optional: false, + }, + { + name: 'right', + type: 'geo_point[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'left', + type: 'geo_shape', + optional: false, + }, + { + name: 'right', + type: 'geo_shape[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'integer[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'left', + type: 'ip', + optional: false, + }, + { + name: 'right', + type: 'ip[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'left', + type: 'keyword', + optional: false, + }, + { + name: 'right', + type: 'keyword[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'left', + type: 'keyword', + optional: false, + }, + { + name: 'right', + type: 'text[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'long[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'left', + type: 'text', + optional: false, + }, + { + name: 'right', + type: 'keyword[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'left', + type: 'text', + optional: false, + }, + { + name: 'right', + type: 'text[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'left', + type: 'version', + optional: false, + }, + { + name: 'right', + type: 'version[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + ], + supportedCommands: ['eval', 'where', 'row', 'sort'], + supportedOptions: undefined, + validate: undefined, + examples: ['ROW a = 1, b = 4, c = 3\n| WHERE c-a IN (3, b / 2, a)'], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const lessThanDefinition: FunctionDefinition = { + type: 'builtin', + name: '<', + description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.less_than', { + defaultMessage: + 'Check if one field is less than another. If either field is multivalued then the result is `null`.', + }), + preview: false, + alias: undefined, + signatures: [ + { + params: [ + { + name: 'left', + type: 'date', + optional: false, + }, + { + name: 'right', + type: 'date', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'date', + optional: false, + }, + { + name: 'right', + type: 'date_nanos', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'date_nanos', + optional: false, + }, + { + name: 'right', + type: 'date', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'date_nanos', + optional: false, + }, + { + name: 'right', + type: 'date_nanos', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'ip', + optional: false, + }, + { + name: 'right', + type: 'ip', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'keyword', + optional: false, + }, + { + name: 'right', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'keyword', + optional: false, + }, + { + name: 'right', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'text', + optional: false, + }, + { + name: 'right', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'text', + optional: false, + }, + { + name: 'right', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'unsigned_long', + optional: false, + }, + { + name: 'right', + type: 'unsigned_long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'version', + optional: false, + }, + { + name: 'right', + type: 'version', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'ip', + }, + { + name: 'right', + type: 'text', + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'text', + constantOnly: true, + }, + { + name: 'right', + type: 'ip', + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'version', + }, + { + name: 'right', + type: 'text', + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'text', + constantOnly: true, + }, + { + name: 'right', + type: 'version', + }, + ], + returnType: 'boolean', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'], + supportedOptions: ['by'], + validate: undefined, + examples: [], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const lessThanOrEqualDefinition: FunctionDefinition = { + type: 'builtin', + name: '<=', + description: i18n.translate( + 'kbn-esql-validation-autocomplete.esql.definitions.less_than_or_equal', + { + defaultMessage: + 'Check if one field is less than or equal to another. If either field is multivalued then the result is `null`.', + } + ), + preview: false, + alias: undefined, + signatures: [ + { + params: [ + { + name: 'left', + type: 'date', + optional: false, + }, + { + name: 'right', + type: 'date', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'date', + optional: false, + }, + { + name: 'right', + type: 'date_nanos', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'date_nanos', + optional: false, + }, + { + name: 'right', + type: 'date', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'date_nanos', + optional: false, + }, + { + name: 'right', + type: 'date_nanos', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'ip', + optional: false, + }, + { + name: 'right', + type: 'ip', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'keyword', + optional: false, + }, + { + name: 'right', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'keyword', + optional: false, + }, + { + name: 'right', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'text', + optional: false, + }, + { + name: 'right', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'text', + optional: false, + }, + { + name: 'right', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'unsigned_long', + optional: false, + }, + { + name: 'right', + type: 'unsigned_long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'version', + optional: false, + }, + { + name: 'right', + type: 'version', + optional: false, + }, + ], + returnType: 'boolean', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'], + supportedOptions: ['by'], + validate: undefined, + examples: [], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const likeDefinition: FunctionDefinition = { + type: 'builtin', + name: 'like', + description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.like', { + defaultMessage: + '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.', + }), + preview: false, + alias: undefined, + signatures: [ + { + params: [ + { + name: 'str', + type: 'keyword', + optional: false, + }, + { + name: 'pattern', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'str', + type: 'text', + optional: false, + }, + { + name: 'pattern', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'str', + type: 'text', + optional: false, + }, + { + name: 'pattern', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'str', + type: 'keyword', + optional: false, + }, + { + name: 'pattern', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + ], + supportedCommands: ['eval', 'where', 'row', 'sort'], + supportedOptions: ['by'], + validate: undefined, + examples: ['FROM employees\n| WHERE first_name LIKE """?b*"""\n| KEEP first_name, last_name'], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const matchOperatorDefinition: FunctionDefinition = { + type: 'builtin', + name: ':', + description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.match_operator', { + defaultMessage: + 'Use `MATCH` to perform a match query on the specified field.\nUsing `MATCH` is equivalent to using the `match` query in the Elasticsearch Query DSL.\n\nMatch can be used on fields from the text family like text and semantic_text,\nas well as other field types like keyword, boolean, dates, and numeric types.\n\nFor a simplified syntax, you can use the match operator `:` operator instead of `MATCH`.\n\n`MATCH` returns true if the provided query matches the row.', + }), + preview: true, + alias: undefined, + signatures: [ + { + params: [ + { + name: 'left', + type: 'boolean', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'boolean', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'boolean', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'keyword', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'date', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'date', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'date', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'keyword', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'date_nanos', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'date_nanos', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'date_nanos', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'keyword', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'double', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'integer', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'keyword', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'long', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'double', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'integer', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'keyword', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'long', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'ip', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'ip', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'ip', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'keyword', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'keyword', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'keyword', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'double', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'integer', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'keyword', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'long', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'text', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'keyword', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'unsigned_long', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'double', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'unsigned_long', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'integer', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'unsigned_long', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'keyword', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'unsigned_long', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'long', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'unsigned_long', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'unsigned_long', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'version', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'keyword', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'version', + optional: false, + fieldsOnly: true, + }, + { + name: 'query', + type: 'version', + optional: false, + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + ], + supportedCommands: ['where'], + supportedOptions: [], + 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 modDefinition: FunctionDefinition = { + type: 'builtin', + name: '%', + description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.mod', { + defaultMessage: + 'Divide one number by another and return the remainder. If either field is multivalued then the result is `null`.', + }), + preview: false, + alias: undefined, + signatures: [ + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'integer', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'left', + type: 'unsigned_long', + optional: false, + }, + { + name: 'right', + type: 'unsigned_long', + optional: false, + }, + ], + returnType: 'unsigned_long', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'], + supportedOptions: ['by'], + validate: (fnDef) => { + const [left, right] = fnDef.args; + const messages = []; + if (!Array.isArray(left) && !Array.isArray(right)) { + if (right.type === 'literal' && isNumericType(right.literalType)) { + if (right.value === 0) { + messages.push({ + type: 'warning' as const, + code: 'moduleByZero', + text: i18n.translate( + 'kbn-esql-validation-autocomplete.esql.divide.warning.zeroModule', + { + defaultMessage: 'Module by zero can return null value: {left}%{right}', + values: { + left: left.text, + right: right.value, + }, + } + ), + location: fnDef.location, + }); + } + } + } + return messages; + }, + examples: [], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const mulDefinition: FunctionDefinition = { + type: 'builtin', + name: '*', + description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.mul', { + defaultMessage: + 'Multiply two numbers together. If either field is multivalued then the result is `null`.', + }), + preview: false, + alias: undefined, + signatures: [ + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'integer', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'left', + type: 'unsigned_long', + optional: false, + }, + { + name: 'right', + type: 'unsigned_long', + optional: false, + }, + ], + returnType: 'unsigned_long', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'], + supportedOptions: ['by'], + validate: undefined, + examples: [], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const negDefinition: FunctionDefinition = { + type: 'builtin', + name: '-', + description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.neg', { + defaultMessage: 'Returns the negation of the argument.', + }), + preview: false, + alias: undefined, + signatures: [ + { + params: [ + { + name: 'left', + type: 'date_period', + optional: false, + }, + ], + returnType: 'date_period', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + ], + returnType: 'integer', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'left', + type: 'time_duration', + optional: false, + }, + ], + returnType: 'time_duration', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics'], + supportedOptions: undefined, + validate: undefined, + examples: [], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const notEqualsDefinition: FunctionDefinition = { + type: 'builtin', + name: '!=', + description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.not_equals', { + defaultMessage: + 'Check if two fields are unequal. If either field is multivalued then the result is `null`.', + }), + preview: false, + alias: undefined, + signatures: [ + { + params: [ + { + name: 'left', + type: 'boolean', + optional: false, + }, + { + name: 'right', + type: 'boolean', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'cartesian_point', + optional: false, + }, + { + name: 'right', + type: 'cartesian_point', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'cartesian_shape', + optional: false, + }, + { + name: 'right', + type: 'cartesian_shape', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'date', + optional: false, + }, + { + name: 'right', + type: 'date', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'date', + optional: false, + }, + { + name: 'right', + type: 'date_nanos', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'date_nanos', + optional: false, + }, + { + name: 'right', + type: 'date', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'date_nanos', + optional: false, + }, + { + name: 'right', + type: 'date_nanos', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'geo_point', + optional: false, + }, + { + name: 'right', + type: 'geo_point', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'geo_shape', + optional: false, + }, + { + name: 'right', + type: 'geo_shape', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'ip', + optional: false, + }, + { + name: 'right', + type: 'ip', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'keyword', + optional: false, + }, + { + name: 'right', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'keyword', + optional: false, + }, + { + name: 'right', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'text', + optional: false, + }, + { + name: 'right', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'text', + optional: false, + }, + { + name: 'right', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'unsigned_long', + optional: false, + }, + { + name: 'right', + type: 'unsigned_long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'version', + optional: false, + }, + { + name: 'right', + type: 'version', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'ip', + }, + { + name: 'right', + type: 'text', + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'text', + constantOnly: true, + }, + { + name: 'right', + type: 'ip', + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'version', + }, + { + name: 'right', + type: 'text', + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'text', + constantOnly: true, + }, + { + name: 'right', + type: 'version', + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'boolean', + }, + { + name: 'right', + type: 'boolean', + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'boolean', + }, + { + name: 'right', + type: 'keyword', + constantOnly: true, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'left', + type: 'keyword', + constantOnly: true, + }, + { + name: 'right', + type: 'boolean', + }, + ], + returnType: 'boolean', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'], + supportedOptions: ['by'], + validate: undefined, + examples: [], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const notInDefinition: FunctionDefinition = { + type: 'builtin', + name: 'not_in', + description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.not_in', { + defaultMessage: + 'The `NOT IN` operator allows testing whether a field or expression does *not* equal any element in a list of literals, fields or expressions.', + }), + ignoreAsSuggestion: true, + + preview: false, + alias: undefined, + signatures: [ + { + params: [ + { + name: 'left', + type: 'boolean', + optional: false, + }, + { + name: 'right', + type: 'boolean[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'left', + type: 'cartesian_point', + optional: false, + }, + { + name: 'right', + type: 'cartesian_point[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'left', + type: 'cartesian_shape', + optional: false, + }, + { + name: 'right', + type: 'cartesian_shape[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'double[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'left', + type: 'geo_point', + optional: false, + }, + { + name: 'right', + type: 'geo_point[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'left', + type: 'geo_shape', + optional: false, + }, + { + name: 'right', + type: 'geo_shape[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'integer[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'left', + type: 'ip', + optional: false, + }, + { + name: 'right', + type: 'ip[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'left', + type: 'keyword', + optional: false, + }, + { + name: 'right', + type: 'keyword[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'left', + type: 'keyword', + optional: false, + }, + { + name: 'right', + type: 'text[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'long[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'left', + type: 'text', + optional: false, + }, + { + name: 'right', + type: 'keyword[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'left', + type: 'text', + optional: false, + }, + { + name: 'right', + type: 'text[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'left', + type: 'version', + optional: false, + }, + { + name: 'right', + type: 'version[]', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + ], + supportedCommands: ['eval', 'where', 'row', 'sort'], + supportedOptions: undefined, + validate: undefined, + examples: [], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const notLikeDefinition: FunctionDefinition = { + type: 'builtin', + name: 'not_like', + description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.not_like', { + defaultMessage: + 'Use `NOT LIKE` to filter data based on string patterns using wildcards. `NOT 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.', + }), + preview: false, + alias: undefined, + signatures: [ + { + params: [ + { + name: 'str', + type: 'keyword', + optional: false, + }, + { + name: 'pattern', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'str', + type: 'text', + optional: false, + }, + { + name: 'pattern', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + ], + supportedCommands: ['eval', 'where', 'row', 'sort'], + supportedOptions: undefined, + validate: undefined, + examples: [], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const notRlikeDefinition: FunctionDefinition = { + type: 'builtin', + name: 'not_rlike', + description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.not_rlike', { + defaultMessage: + 'Use `NOT RLIKE` to filter data based on string patterns using using\nregular expressions. `NOT RLIKE` usually acts on a field placed on\nthe left-hand side of the operator, but it can also act on a constant (literal)\nexpression. The right-hand side of the operator represents the pattern.', + }), + preview: false, + alias: undefined, + signatures: [ + { + params: [ + { + name: 'str', + type: 'keyword', + optional: false, + }, + { + name: 'pattern', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'str', + type: 'text', + optional: false, + }, + { + name: 'pattern', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + ], + supportedCommands: ['eval', 'where', 'row', 'sort'], + supportedOptions: undefined, + validate: undefined, + examples: [], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const rlikeDefinition: FunctionDefinition = { + type: 'builtin', + name: 'rlike', + description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.rlike', { + defaultMessage: + 'Use `RLIKE` to filter data based on string patterns using using\nregular expressions. `RLIKE` usually acts on a field placed on\nthe left-hand side of the operator, but it can also act on a constant (literal)\nexpression. The right-hand side of the operator represents the pattern.', + }), + preview: false, + alias: undefined, + signatures: [ + { + params: [ + { + name: 'str', + type: 'keyword', + optional: false, + }, + { + name: 'pattern', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'str', + type: 'text', + optional: false, + }, + { + name: 'pattern', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'str', + type: 'text', + optional: false, + }, + { + name: 'pattern', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'str', + type: 'keyword', + optional: false, + }, + { + name: 'pattern', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + ], + supportedCommands: ['eval', 'where', 'row', 'sort'], + supportedOptions: ['by'], + validate: undefined, + examples: [ + 'FROM employees\n| WHERE first_name RLIKE """.leja.*"""\n| KEEP first_name, last_name', + ], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const subDefinition: FunctionDefinition = { + type: 'builtin', + name: '-', + description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.sub', { + defaultMessage: + 'Subtract one number from another. If either field is multivalued then the result is `null`.', + }), + preview: false, + alias: undefined, + signatures: [ + { + params: [ + { + name: 'left', + type: 'date', + optional: false, + }, + { + name: 'right', + type: 'date_period', + optional: false, + }, + ], + returnType: 'date', + }, + { + params: [ + { + name: 'left', + type: 'date', + optional: false, + }, + { + name: 'right', + type: 'time_duration', + optional: false, + }, + ], + returnType: 'date', + }, + { + params: [ + { + name: 'left', + type: 'date_nanos', + optional: false, + }, + { + name: 'right', + type: 'date_period', + optional: false, + }, + ], + returnType: 'date_nanos', + }, + { + params: [ + { + name: 'left', + type: 'date_nanos', + optional: false, + }, + { + name: 'right', + type: 'time_duration', + optional: false, + }, + ], + returnType: 'date_nanos', + }, + { + params: [ + { + name: 'left', + type: 'date_period', + optional: false, + }, + { + name: 'right', + type: 'date_nanos', + optional: false, + }, + ], + returnType: 'date_nanos', + }, + { + params: [ + { + name: 'left', + type: 'date_period', + optional: false, + }, + { + name: 'right', + type: 'date_period', + optional: false, + }, + ], + returnType: 'date_period', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'left', + type: 'double', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'integer', + }, + { + params: [ + { + name: 'left', + type: 'integer', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'integer', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'left', + type: 'long', + optional: false, + }, + { + name: 'right', + type: 'long', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'left', + type: 'time_duration', + optional: false, + }, + { + name: 'right', + type: 'date_nanos', + optional: false, + }, + ], + returnType: 'date_nanos', + }, + { + params: [ + { + name: 'left', + type: 'time_duration', + optional: false, + }, + { + name: 'right', + type: 'time_duration', + optional: false, + }, + ], + returnType: 'time_duration', + }, + { + params: [ + { + name: 'left', + type: 'unsigned_long', + optional: false, + }, + { + name: 'right', + type: 'unsigned_long', + optional: false, + }, + ], + returnType: 'unsigned_long', + }, + { + params: [ + { + name: 'left', + type: 'time_literal', + }, + { + name: 'right', + type: 'date', + }, + ], + returnType: 'date', + }, + { + params: [ + { + name: 'left', + type: 'date', + }, + { + name: 'right', + type: 'time_literal', + }, + ], + returnType: 'date', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'], + supportedOptions: ['by'], + validate: undefined, + examples: [], +}; +export const operatorsFunctionDefinitions = [ + addDefinition, + divDefinition, + equalsDefinition, + greaterThanDefinition, + greaterThanOrEqualDefinition, + inDefinition, + lessThanDefinition, + lessThanOrEqualDefinition, + likeDefinition, + matchOperatorDefinition, + modDefinition, + mulDefinition, + negDefinition, + notEqualsDefinition, + notInDefinition, + notLikeDefinition, + notRlikeDefinition, + rlikeDefinition, + subDefinition, +]; diff --git a/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/definitions/generated/scalar_functions.ts b/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/definitions/generated/scalar_functions.ts index a38271f59fdca..7a8deced8f9de 100644 --- a/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/definitions/generated/scalar_functions.ts +++ b/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/definitions/generated/scalar_functions.ts @@ -3713,6 +3713,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'boolean', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -3729,6 +3730,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'keyword', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -3745,6 +3747,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'date', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -3761,6 +3764,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'keyword', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -3777,6 +3781,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'date_nanos', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -3793,6 +3798,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'keyword', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -3809,6 +3815,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'double', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -3825,6 +3832,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'integer', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -3841,6 +3849,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'keyword', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -3857,6 +3866,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'long', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -3873,6 +3883,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'double', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -3889,6 +3900,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'integer', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -3905,6 +3917,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'keyword', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -3921,6 +3934,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'long', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -3937,6 +3951,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'ip', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -3953,6 +3968,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'keyword', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -3969,6 +3985,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'keyword', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -3985,6 +4002,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'double', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -4001,6 +4019,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'integer', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -4017,6 +4036,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'keyword', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -4033,6 +4053,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'long', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -4049,6 +4070,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'keyword', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -4065,6 +4087,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'double', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -4081,6 +4104,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'integer', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -4097,6 +4121,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'keyword', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -4113,6 +4138,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'long', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -4129,6 +4155,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'unsigned_long', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -4145,6 +4172,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'keyword', optional: false, + constantOnly: true, }, ], returnType: 'boolean', @@ -4161,6 +4189,7 @@ const matchDefinition: FunctionDefinition = { name: 'query', type: 'version', optional: false, + constantOnly: true, }, ], returnType: 'boolean', diff --git a/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/definitions/types.ts b/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/definitions/types.ts index 6a9442faca1fa..a894d3ab271ae 100644 --- a/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/definitions/types.ts +++ b/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/definitions/types.ts @@ -93,6 +93,13 @@ const arrayTypes = [ 'any[]', 'date[]', 'date_period[]', + 'ip[]', + 'cartesian_point[]', + 'cartesian_shape[]', + 'geo_point[]', + 'geo_shape[]', + 'version[]', + 'date_nanos[]', ] as const; export type ArrayType = (typeof arrayTypes)[number]; @@ -118,8 +125,50 @@ export const isReturnType = (str: string | FunctionParameterType): str is Functi str !== 'unsupported' && (dataTypes.includes(str as SupportedDataType) || str === 'unknown' || str === 'any'); +export interface Signature { + params: Array<{ + name: string; + type: FunctionParameterType; + optional?: boolean; + supportsWildcard?: boolean; + /** + * If set, this parameter does not accept a field. It only accepts a constant, + * though a function can be used to create the value. (e.g. now() for dates or concat() for strings) + */ + constantOnly?: boolean; + /** + * Default to false. If set to true, this parameter does not accept a function or literal, only fields. + */ + fieldsOnly?: boolean; + /** + * if provided this means that the value must be one + * of the options in the array iff the value is a literal. + * + * String values are case insensitive. + * + * If the value is not a literal, this field is ignored because + * we can't check the return value of a function to see if it + * matches one of the options prior to runtime. + */ + acceptedValues?: string[]; + /** + * Must only be included _in addition to_ literalOptions. + * + * If provided this is the list of suggested values that + * will show up in the autocomplete. If omitted, the literalOptions + * will be used as suggestions. + * + * This is useful for functions that accept + * values that we don't want to show as suggestions. + */ + literalSuggestions?: string[]; + }>; + minParams?: number; + returnType: FunctionReturnType; +} + export interface FunctionDefinition { - type: 'builtin' | 'agg' | 'eval'; + type: 'builtin' | 'agg' | 'eval' | 'operator'; preview?: boolean; ignoreAsSuggestion?: boolean; name: string; @@ -127,49 +176,10 @@ export interface FunctionDefinition { description: string; supportedCommands: string[]; supportedOptions?: string[]; - signatures: Array<{ - params: Array<{ - name: string; - type: FunctionParameterType; - optional?: boolean; - supportsWildcard?: boolean; - /** - * If set, this parameter does not accept a field. It only accepts a constant, - * though a function can be used to create the value. (e.g. now() for dates or concat() for strings) - */ - constantOnly?: boolean; - /** - * Default to false. If set to true, this parameter does not accept a function or literal, only fields. - */ - fieldsOnly?: boolean; - /** - * if provided this means that the value must be one - * of the options in the array iff the value is a literal. - * - * String values are case insensitive. - * - * If the value is not a literal, this field is ignored because - * we can't check the return value of a function to see if it - * matches one of the options prior to runtime. - */ - acceptedValues?: string[]; - /** - * Must only be included _in addition to_ literalOptions. - * - * If provided this is the list of suggested values that - * will show up in the autocomplete. If omitted, the literalOptions - * will be used as suggestions. - * - * This is useful for functions that accept - * values that we don't want to show as suggestions. - */ - literalSuggestions?: string[]; - }>; - minParams?: number; - returnType: FunctionReturnType; - }>; + signatures: Signature[]; examples?: string[]; validate?: (fnDef: ESQLFunction) => ESQLMessage[]; + operator?: string; } export interface CommandBaseDefinition { diff --git a/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/shared/constants.ts b/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/shared/constants.ts index e566c42905c5c..33567217bfe95 100644 --- a/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/shared/constants.ts +++ b/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/shared/constants.ts @@ -17,7 +17,7 @@ export const SINGLE_BACKTICK = '`'; export const METADATA_FIELDS = ['_version', '_id', '_index', '_source', '_ignored', '_index_mode']; -export const FULL_TEXT_SEARCH_FUNCTIONS = ['match', 'qstr', 'kql']; +export const FULL_TEXT_SEARCH_FUNCTIONS = ['match', 'match_operator', 'qstr', 'kql']; export const UNSUPPORTED_COMMANDS_BEFORE_QSTR = new Set([ 'show', 'row', diff --git a/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/validation/esql_validation_meta_tests.json b/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/validation/esql_validation_meta_tests.json index 16b89dcc8306d..0994b6abd3e09 100644 --- a/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/validation/esql_validation_meta_tests.json +++ b/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/validation/esql_validation_meta_tests.json @@ -336,7 +336,7 @@ "query": "row var = 1 in (", "error": [ "SyntaxError: mismatched input '' expecting {QUOTED_STRING, INTEGER_LITERAL, DECIMAL_LITERAL, 'false', '(', 'null', '?', 'true', '+', '-', NAMED_OR_POSITIONAL_PARAM, OPENING_BRACKET, UNQUOTED_IDENTIFIER, QUOTED_IDENTIFIER}", - "Error: [in] function expects exactly 2 arguments, got 1." + "Error: [in] function expects at least 2 arguments, got 1." ], "warning": [] }, @@ -384,22 +384,30 @@ }, { "query": "row var = 1 in (\"a\", \"b\", \"c\")", - "error": [], + "error": [ + "Argument of [in] must be [integer[]], found value [(\"a\", \"b\", \"c\")] type [(keyword, keyword, keyword)]" + ], "warning": [] }, { "query": "row var = 5 in (\"a\", \"b\", \"c\")", - "error": [], + "error": [ + "Argument of [in] must be [integer[]], found value [(\"a\", \"b\", \"c\")] type [(keyword, keyword, keyword)]" + ], "warning": [] }, { "query": "row var = 5 not in (\"a\", \"b\", \"c\")", - "error": [], + "error": [ + "Argument of [not_in] must be [integer[]], found value [(\"a\", \"b\", \"c\")] type [(keyword, keyword, keyword)]" + ], "warning": [] }, { "query": "row var = 5 not in (1, 2, 3, \"a\")", - "error": [], + "error": [ + "Argument of [not_in] must be [integer[]], found value [(1, 2, 3, \"a\")] type [(integer, integer, integer, keyword)]" + ], "warning": [] }, { @@ -847,28 +855,28 @@ { "query": "row var = 5 like \"?a\"", "error": [ - "Argument of [like] must be [text], found value [5] type [integer]" + "Argument of [like] must be [keyword], found value [5] type [integer]" ], "warning": [] }, { "query": "row var = 5 NOT like \"?a\"", "error": [ - "Argument of [not_like] must be [text], found value [5] type [integer]" + "Argument of [not_like] must be [keyword], found value [5] type [integer]" ], "warning": [] }, { "query": "row var = NOT 5 like \"?a\"", "error": [ - "Argument of [like] must be [text], found value [5] type [integer]" + "Argument of [like] must be [keyword], found value [5] type [integer]" ], "warning": [] }, { "query": "row var = NOT 5 NOT like \"?a\"", "error": [ - "Argument of [not_like] must be [text], found value [5] type [integer]" + "Argument of [not_like] must be [keyword], found value [5] type [integer]" ], "warning": [] }, @@ -895,28 +903,28 @@ { "query": "row var = 5 rlike \"?a\"", "error": [ - "Argument of [rlike] must be [text], found value [5] type [integer]" + "Argument of [rlike] must be [keyword], found value [5] type [integer]" ], "warning": [] }, { "query": "row var = 5 NOT rlike \"?a\"", "error": [ - "Argument of [not_rlike] must be [text], found value [5] type [integer]" + "Argument of [not_rlike] must be [keyword], found value [5] type [integer]" ], "warning": [] }, { "query": "row var = NOT 5 rlike \"?a\"", "error": [ - "Argument of [rlike] must be [text], found value [5] type [integer]" + "Argument of [rlike] must be [keyword], found value [5] type [integer]" ], "warning": [] }, { "query": "row var = NOT 5 NOT rlike \"?a\"", "error": [ - "Argument of [not_rlike] must be [text], found value [5] type [integer]" + "Argument of [not_rlike] must be [keyword], found value [5] type [integer]" ], "warning": [] }, @@ -1060,7 +1068,7 @@ { "query": "row 1 years + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 years] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -1125,7 +1133,7 @@ { "query": "row 1 quarter + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 quarter] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -1190,7 +1198,7 @@ { "query": "row 1 quarters + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 quarters] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -1255,7 +1263,7 @@ { "query": "row 1 month + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 month] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -1320,7 +1328,7 @@ { "query": "row 1 months + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 months] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -1385,7 +1393,7 @@ { "query": "row 1 week + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 week] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -1450,7 +1458,7 @@ { "query": "row 1 weeks + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 weeks] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -1515,7 +1523,7 @@ { "query": "row 1 day + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 day] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -1580,7 +1588,7 @@ { "query": "row 1 days + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 days] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -1645,7 +1653,7 @@ { "query": "row 1 hour + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 hour] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -1710,7 +1718,7 @@ { "query": "row 1 hours + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 hours] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -1775,7 +1783,7 @@ { "query": "row 1 minute + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 minute] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -1840,7 +1848,7 @@ { "query": "row 1 minutes + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 minutes] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -1905,7 +1913,7 @@ { "query": "row 1 second + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 second] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -1970,7 +1978,7 @@ { "query": "row 1 seconds + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 seconds] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -2035,7 +2043,7 @@ { "query": "row 1 millisecond + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 millisecond] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -2100,7 +2108,7 @@ { "query": "row 1 milliseconds + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 milliseconds] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -3634,28 +3642,28 @@ { "query": "from a_index | where doubleField like \"?a\"", "error": [ - "Argument of [like] must be [text], found value [doubleField] type [double]" + "Argument of [like] must be [keyword], found value [doubleField] type [double]" ], "warning": [] }, { "query": "from a_index | where doubleField NOT like \"?a\"", "error": [ - "Argument of [not_like] must be [text], found value [doubleField] type [double]" + "Argument of [not_like] must be [keyword], found value [doubleField] type [double]" ], "warning": [] }, { "query": "from a_index | where NOT doubleField like \"?a\"", "error": [ - "Argument of [like] must be [text], found value [doubleField] type [double]" + "Argument of [like] must be [keyword], found value [doubleField] type [double]" ], "warning": [] }, { "query": "from a_index | where NOT doubleField NOT like \"?a\"", "error": [ - "Argument of [not_like] must be [text], found value [doubleField] type [double]" + "Argument of [not_like] must be [keyword], found value [doubleField] type [double]" ], "warning": [] }, @@ -3682,28 +3690,28 @@ { "query": "from a_index | where doubleField rlike \"?a\"", "error": [ - "Argument of [rlike] must be [text], found value [doubleField] type [double]" + "Argument of [rlike] must be [keyword], found value [doubleField] type [double]" ], "warning": [] }, { "query": "from a_index | where doubleField NOT rlike \"?a\"", "error": [ - "Argument of [not_rlike] must be [text], found value [doubleField] type [double]" + "Argument of [not_rlike] must be [keyword], found value [doubleField] type [double]" ], "warning": [] }, { "query": "from a_index | where NOT doubleField rlike \"?a\"", "error": [ - "Argument of [rlike] must be [text], found value [doubleField] type [double]" + "Argument of [rlike] must be [keyword], found value [doubleField] type [double]" ], "warning": [] }, { "query": "from a_index | where NOT doubleField NOT rlike \"?a\"", "error": [ - "Argument of [not_rlike] must be [text], found value [doubleField] type [double]" + "Argument of [not_rlike] must be [keyword], found value [doubleField] type [double]" ], "warning": [] }, @@ -6329,7 +6337,7 @@ { "query": "from a_index | eval doubleField == \"2022\"", "error": [ - "Argument of [==] must be [date], found value [doubleField] type [double]" + "Argument of [==] must be [boolean], found value [doubleField] type [double]" ], "warning": [] }, @@ -6468,7 +6476,7 @@ { "query": "from a_index | eval doubleField != \"2022\"", "error": [ - "Argument of [!=] must be [date], found value [doubleField] type [double]" + "Argument of [!=] must be [boolean], found value [doubleField] type [double]" ], "warning": [] }, @@ -6585,7 +6593,7 @@ { "query": "from a_index | eval 1 + \"1\"", "error": [ - "Argument of [+] must be [date_period], found value [1] type [integer]" + "Argument of [+] must be [date], found value [1] type [integer]" ], "warning": [] }, @@ -6621,7 +6629,7 @@ { "query": "from a_index | eval 1 - \"1\"", "error": [ - "Argument of [-] must be [date_period], found value [1] type [integer]" + "Argument of [-] must be [date], found value [1] type [integer]" ], "warning": [] }, @@ -6808,28 +6816,28 @@ { "query": "from a_index | eval doubleField like \"?a\"", "error": [ - "Argument of [like] must be [text], found value [doubleField] type [double]" + "Argument of [like] must be [keyword], found value [doubleField] type [double]" ], "warning": [] }, { "query": "from a_index | eval doubleField NOT like \"?a\"", "error": [ - "Argument of [not_like] must be [text], found value [doubleField] type [double]" + "Argument of [not_like] must be [keyword], found value [doubleField] type [double]" ], "warning": [] }, { "query": "from a_index | eval NOT doubleField like \"?a\"", "error": [ - "Argument of [like] must be [text], found value [doubleField] type [double]" + "Argument of [like] must be [keyword], found value [doubleField] type [double]" ], "warning": [] }, { "query": "from a_index | eval NOT doubleField NOT like \"?a\"", "error": [ - "Argument of [not_like] must be [text], found value [doubleField] type [double]" + "Argument of [not_like] must be [keyword], found value [doubleField] type [double]" ], "warning": [] }, @@ -6856,28 +6864,28 @@ { "query": "from a_index | eval doubleField rlike \"?a\"", "error": [ - "Argument of [rlike] must be [text], found value [doubleField] type [double]" + "Argument of [rlike] must be [keyword], found value [doubleField] type [double]" ], "warning": [] }, { "query": "from a_index | eval doubleField NOT rlike \"?a\"", "error": [ - "Argument of [not_rlike] must be [text], found value [doubleField] type [double]" + "Argument of [not_rlike] must be [keyword], found value [doubleField] type [double]" ], "warning": [] }, { "query": "from a_index | eval NOT doubleField rlike \"?a\"", "error": [ - "Argument of [rlike] must be [text], found value [doubleField] type [double]" + "Argument of [rlike] must be [keyword], found value [doubleField] type [double]" ], "warning": [] }, { "query": "from a_index | eval NOT doubleField NOT rlike \"?a\"", "error": [ - "Argument of [not_rlike] must be [text], found value [doubleField] type [double]" + "Argument of [not_rlike] must be [keyword], found value [doubleField] type [double]" ], "warning": [] }, @@ -6928,7 +6936,9 @@ }, { "query": "from a_index | eval 1 in (\"a\", \"b\", \"c\")", - "error": [], + "error": [ + "Argument of [in] must be [integer[]], found value [(\"a\", \"b\", \"c\")] type [(keyword, keyword, keyword)]" + ], "warning": [] }, { @@ -6985,7 +6995,7 @@ "query": "from a_index | eval textField in textField)", "error": [ "SyntaxError: missing '(' at 'textField'", - "Error: [in] function expects exactly 2 arguments, got 1." + "Error: [in] function expects at least 2 arguments, got 1." ], "warning": [] }, @@ -7167,7 +7177,7 @@ { "query": "from a_index | eval 1 years + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 years] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -7237,7 +7247,7 @@ { "query": "from a_index | eval 1 quarter + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 quarter] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -7307,7 +7317,7 @@ { "query": "from a_index | eval 1 quarters + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 quarters] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -7377,7 +7387,7 @@ { "query": "from a_index | eval 1 month + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 month] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -7447,7 +7457,7 @@ { "query": "from a_index | eval 1 months + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 months] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -7517,7 +7527,7 @@ { "query": "from a_index | eval 1 week + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 week] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -7587,7 +7597,7 @@ { "query": "from a_index | eval 1 weeks + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 weeks] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -7657,7 +7667,7 @@ { "query": "from a_index | eval 1 day + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 day] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -7727,7 +7737,7 @@ { "query": "from a_index | eval 1 days + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 days] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -7797,7 +7807,7 @@ { "query": "from a_index | eval 1 hour + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 hour] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -7867,7 +7877,7 @@ { "query": "from a_index | eval 1 hours + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 hours] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -7937,7 +7947,7 @@ { "query": "from a_index | eval 1 minute + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 minute] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -8007,7 +8017,7 @@ { "query": "from a_index | eval 1 minutes + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 minutes] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -8077,7 +8087,7 @@ { "query": "from a_index | eval 1 second + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 second] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -8147,7 +8157,7 @@ { "query": "from a_index | eval 1 seconds + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 seconds] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -8217,7 +8227,7 @@ { "query": "from a_index | eval 1 millisecond + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 millisecond] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -8287,7 +8297,7 @@ { "query": "from a_index | eval 1 milliseconds + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 milliseconds] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -8357,7 +8367,7 @@ { "query": "from a_index | eval 1 ms + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 ms] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -8427,7 +8437,7 @@ { "query": "from a_index | eval 1 s + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 s] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -8497,7 +8507,7 @@ { "query": "from a_index | eval 1 m + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 m] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -8567,7 +8577,7 @@ { "query": "from a_index | eval 1 h + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 h] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -8637,7 +8647,7 @@ { "query": "from a_index | eval 1 d + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 d] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -8707,7 +8717,7 @@ { "query": "from a_index | eval 1 w + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 w] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -8777,7 +8787,7 @@ { "query": "from a_index | eval 1 mo + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 mo] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -8847,7 +8857,7 @@ { "query": "from a_index | eval 1 q + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 q] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -8917,7 +8927,7 @@ { "query": "from a_index | eval 1 y + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 y] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -8987,7 +8997,7 @@ { "query": "from a_index | eval 1 yr + 1 year", "error": [ - "Argument of [+] must be [date], found value [1 yr] type [duration]" + "Argument of [+] must be [date], found value [1 year] type [duration]" ], "warning": [] }, @@ -9590,7 +9600,7 @@ { "query": "from a_index | eval 1 + \"2\"", "error": [ - "Argument of [+] must be [date_period], found value [1] type [integer]" + "Argument of [+] must be [date], found value [1] type [integer]" ], "warning": [] }, diff --git a/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/validation/validation.test.ts b/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/validation/validation.test.ts index c83ae10a8d3e7..37b100ba3eaa8 100644 --- a/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/validation/validation.test.ts +++ b/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/validation/validation.test.ts @@ -336,7 +336,7 @@ describe('validation logic', () => { ]); testErrorsAndWarnings('row var = 1 in (', [ "SyntaxError: mismatched input '' expecting {QUOTED_STRING, INTEGER_LITERAL, DECIMAL_LITERAL, 'false', '(', 'null', '?', 'true', '+', '-', NAMED_OR_POSITIONAL_PARAM, OPENING_BRACKET, UNQUOTED_IDENTIFIER, QUOTED_IDENTIFIER}", - 'Error: [in] function expects exactly 2 arguments, got 1.', + 'Error: [in] function expects at least 2 arguments, got 1.', ]); testErrorsAndWarnings('row var = 1 not in ', [ "SyntaxError: mismatched input '' expecting '('", @@ -349,16 +349,16 @@ describe('validation logic', () => { testErrorsAndWarnings('row var = "a" in ("a", "b", "c")', []); testErrorsAndWarnings('row var = "a" not in ("a", "b", "c")', []); testErrorsAndWarnings('row var = 1 in ("a", "b", "c")', [ - // 'Argument of [in] must be [number[]], found value [("a", "b", "c")] type [(string, string, string)]', + 'Argument of [in] must be [integer[]], found value [("a", "b", "c")] type [(keyword, keyword, keyword)]', ]); testErrorsAndWarnings('row var = 5 in ("a", "b", "c")', [ - // 'Argument of [in] must be [number[]], found value [("a", "b", "c")] type [(string, string, string)]', + 'Argument of [in] must be [integer[]], found value [("a", "b", "c")] type [(keyword, keyword, keyword)]', ]); testErrorsAndWarnings('row var = 5 not in ("a", "b", "c")', [ - // 'Argument of [not_in] must be [number[]], found value [("a", "b", "c")] type [(string, string, string)]', + 'Argument of [not_in] must be [integer[]], found value [("a", "b", "c")] type [(keyword, keyword, keyword)]', ]); testErrorsAndWarnings('row var = 5 not in (1, 2, 3, "a")', [ - // 'Argument of [not_in] must be [number[]], found value [(1, 2, 3, "a")] type [(number, number, number, string)]', + 'Argument of [not_in] must be [integer[]], found value [(1, 2, 3, "a")] type [(integer, integer, integer, keyword)]', ]); // test that "and" and "or" accept null... not sure if this is the best place or not... @@ -391,6 +391,7 @@ describe('validation logic', () => { testErrorsAndWarnings(`row var = ${valueTypeB} ${op} ${valueTypeA}`, []); } } + for (const op of ['+', '-', '*', '/', '%']) { testErrorsAndWarnings(`row var = 1 ${op} 1`, []); testErrorsAndWarnings(`row var = (5 ${op} 1)`, []); @@ -411,16 +412,16 @@ describe('validation logic', () => { testErrorsAndWarnings(`row var = NOT "a" ${op} "?a"`, []); testErrorsAndWarnings(`row var = NOT "a" NOT ${op} "?a"`, []); testErrorsAndWarnings(`row var = 5 ${op} "?a"`, [ - `Argument of [${op}] must be [text], found value [5] type [integer]`, + `Argument of [${op}] must be [keyword], found value [5] type [integer]`, ]); testErrorsAndWarnings(`row var = 5 NOT ${op} "?a"`, [ - `Argument of [not_${op}] must be [text], found value [5] type [integer]`, + `Argument of [not_${op}] must be [keyword], found value [5] type [integer]`, ]); testErrorsAndWarnings(`row var = NOT 5 ${op} "?a"`, [ - `Argument of [${op}] must be [text], found value [5] type [integer]`, + `Argument of [${op}] must be [keyword], found value [5] type [integer]`, ]); testErrorsAndWarnings(`row var = NOT 5 NOT ${op} "?a"`, [ - `Argument of [not_${op}] must be [text], found value [5] type [integer]`, + `Argument of [not_${op}] must be [keyword], found value [5] type [integer]`, ]); } @@ -455,7 +456,7 @@ describe('validation logic', () => { testErrorsAndWarnings(`row var = now() - 1 ${capitalize(timeLiteral.name)}`, []); testErrorsAndWarnings(`row var = now() + 1 ${timeLiteral.name}`, []); testErrorsAndWarnings(`row 1 ${timeLiteral.name} + 1 year`, [ - `Argument of [+] must be [date], found value [1 ${timeLiteral.name}] type [duration]`, + `Argument of [+] must be [date], found value [1 year] type [duration]`, ]); for (const op of ['*', '/', '%']) { testErrorsAndWarnings(`row var = now() ${op} 1 ${timeLiteral.name}`, [ @@ -860,16 +861,16 @@ describe('validation logic', () => { testErrorsAndWarnings(`from a_index | where NOT textField ${op} "?a"`, []); testErrorsAndWarnings(`from a_index | where NOT textField NOT ${op} "?a"`, []); testErrorsAndWarnings(`from a_index | where doubleField ${op} "?a"`, [ - `Argument of [${op}] must be [text], found value [doubleField] type [double]`, + `Argument of [${op}] must be [keyword], found value [doubleField] type [double]`, ]); testErrorsAndWarnings(`from a_index | where doubleField NOT ${op} "?a"`, [ - `Argument of [not_${op}] must be [text], found value [doubleField] type [double]`, + `Argument of [not_${op}] must be [keyword], found value [doubleField] type [double]`, ]); testErrorsAndWarnings(`from a_index | where NOT doubleField ${op} "?a"`, [ - `Argument of [${op}] must be [text], found value [doubleField] type [double]`, + `Argument of [${op}] must be [keyword], found value [doubleField] type [double]`, ]); testErrorsAndWarnings(`from a_index | where NOT doubleField NOT ${op} "?a"`, [ - `Argument of [not_${op}] must be [text], found value [doubleField] type [double]`, + `Argument of [not_${op}] must be [keyword], found value [doubleField] type [double]`, ]); } @@ -1054,7 +1055,9 @@ describe('validation logic', () => { `Argument of [${op}] must be [double], found value [keywordField] type [keyword]`, ]); testErrorsAndWarnings(`from a_index | eval doubleField ${op} "2022"`, [ - `Argument of [${op}] must be [date], found value [doubleField] type [double]`, + op === '==' || op === '!=' + ? `Argument of [${op}] must be [boolean], found value [doubleField] type [double]` + : `Argument of [${op}] must be [date], found value [doubleField] type [double]`, ]); testErrorsAndWarnings(`from a_index | eval dateField ${op} keywordField`, [ @@ -1127,7 +1130,7 @@ describe('validation logic', () => { testErrorsAndWarnings( `from a_index | eval 1 ${op} "1"`, ['+', '-'].includes(op) - ? [`Argument of [${op}] must be [date_period], found value [1] type [integer]`] + ? [`Argument of [${op}] must be [date], found value [1] type [integer]`] : [`Argument of [${op}] must be [double], found value [\"1\"] type [keyword]`] ); testErrorsAndWarnings( @@ -1159,16 +1162,16 @@ describe('validation logic', () => { testErrorsAndWarnings(`from a_index | eval NOT textField ${op} "?a"`, []); testErrorsAndWarnings(`from a_index | eval NOT textField NOT ${op} "?a"`, []); testErrorsAndWarnings(`from a_index | eval doubleField ${op} "?a"`, [ - `Argument of [${op}] must be [text], found value [doubleField] type [double]`, + `Argument of [${op}] must be [keyword], found value [doubleField] type [double]`, ]); testErrorsAndWarnings(`from a_index | eval doubleField NOT ${op} "?a"`, [ - `Argument of [not_${op}] must be [text], found value [doubleField] type [double]`, + `Argument of [not_${op}] must be [keyword], found value [doubleField] type [double]`, ]); testErrorsAndWarnings(`from a_index | eval NOT doubleField ${op} "?a"`, [ - `Argument of [${op}] must be [text], found value [doubleField] type [double]`, + `Argument of [${op}] must be [keyword], found value [doubleField] type [double]`, ]); testErrorsAndWarnings(`from a_index | eval NOT doubleField NOT ${op} "?a"`, [ - `Argument of [not_${op}] must be [text], found value [doubleField] type [double]`, + `Argument of [not_${op}] must be [keyword], found value [doubleField] type [double]`, ]); } // test lists @@ -1182,7 +1185,7 @@ describe('validation logic', () => { testErrorsAndWarnings('from a_index | eval textField not in ("a", "b", "c")', []); testErrorsAndWarnings('from a_index | eval textField not in ("a", "b", "c", textField)', []); testErrorsAndWarnings('from a_index | eval 1 in ("a", "b", "c")', [ - // 'Argument of [in] must be [number[]], found value [("a", "b", "c")] type [(string, string, string)]', + 'Argument of [in] must be [integer[]], found value [("a", "b", "c")] type [(keyword, keyword, keyword)]', ]); testErrorsAndWarnings('from a_index | eval doubleField in ("a", "b", "c")', [ // 'Argument of [in] must be [number[]], found value [("a", "b", "c")] type [(string, string, string)]', @@ -1216,7 +1219,7 @@ describe('validation logic', () => { testErrorsAndWarnings('from a_index | eval textField in textField)', [ "SyntaxError: missing '(' at 'textField'", - 'Error: [in] function expects exactly 2 arguments, got 1.', + 'Error: [in] function expects at least 2 arguments, got 1.', ]); testErrorsAndWarnings('from a_index | eval textField not in textField', [ "SyntaxError: missing '(' at 'textField'", @@ -1274,7 +1277,7 @@ describe('validation logic', () => { testErrorsAndWarnings(`from a_index | eval var = dateField - 1 ${capitalize(unit)}`, []); testErrorsAndWarnings(`from a_index | eval var = dateField + 1 ${unit}`, []); testErrorsAndWarnings(`from a_index | eval 1 ${unit} + 1 year`, [ - `Argument of [+] must be [date], found value [1 ${unit}] type [duration]`, + `Argument of [+] must be [date], found value [1 year] type [duration]`, ]); for (const op of ['*', '/', '%']) { testErrorsAndWarnings(`from a_index | eval var = now() ${op} 1 ${unit}`, [ @@ -1649,7 +1652,7 @@ describe('validation logic', () => { testErrorsAndWarnings('from a_index | eval 1 + "2"', [ // just a counter-case to make sure the previous test is meaningful - 'Argument of [+] must be [date_period], found value [1] type [integer]', + 'Argument of [+] must be [date], found value [1] type [integer]', ]); testErrorsAndWarnings( 'from a_index | eval trim(to_double("23")::keyword::double::long::keyword::double)', diff --git a/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/validation/validation.ts b/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/validation/validation.ts index 423e85e297251..e5d5ef0362f83 100644 --- a/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/validation/validation.ts +++ b/src/platform/packages/shared/kbn-esql-validation-autocomplete/src/validation/validation.ts @@ -619,7 +619,29 @@ function validateFunction({ } // at this point we're sure that at least one signature is matching const failingSignatures: ESQLMessage[][] = []; - for (const signature of matchingSignatures) { + let relevantFuncSignatures = matchingSignatures; + const enrichedArgs = fn.args; + + if (fn.name === 'in' || fn.name === 'not_in') { + for (let argIndex = 1; argIndex < fn.args.length; argIndex++) { + relevantFuncSignatures = fnDefinition.signatures.filter( + (s) => + s.params?.length >= argIndex && + s.params.slice(0, argIndex).every(({ type: dataType }, idx) => { + const arg = enrichedArgs[idx]; + + if (isLiteralItem(arg)) { + return ( + dataType === arg.literalType || compareTypesWithLiterals(dataType, arg.literalType) + ); + } + return false; // Non-literal arguments don't match + }) + ); + } + } + + for (const signature of relevantFuncSignatures) { const failingSignature: ESQLMessage[] = []; fn.args.forEach((outerArg, index) => { const argDef = getParamAtPosition(signature, index); @@ -674,7 +696,7 @@ function validateFunction({ } } - if (failingSignatures.length && failingSignatures.length === matchingSignatures.length) { + if (failingSignatures.length && failingSignatures.length === relevantFuncSignatures.length) { const failingSignatureOrderedByErrorCount = failingSignatures .map((arr, index) => ({ index, count: arr.length })) .sort((a, b) => a.count - b.count); diff --git a/x-pack/platform/plugins/private/translations/translations/fr-FR.json b/x-pack/platform/plugins/private/translations/translations/fr-FR.json index 923060ba0825c..9ced65c7f0520 100644 --- a/x-pack/platform/plugins/private/translations/translations/fr-FR.json +++ b/x-pack/platform/plugins/private/translations/translations/fr-FR.json @@ -5302,19 +5302,16 @@ "kbn-esql-validation-autocomplete.esql.definition.equalToDoc": "Égal à", "kbn-esql-validation-autocomplete.esql.definition.greaterThanDoc": "Supérieur à", "kbn-esql-validation-autocomplete.esql.definition.greaterThanOrEqualToDoc": "Supérieur ou égal à", - "kbn-esql-validation-autocomplete.esql.definition.inDoc": "Teste si la valeur d'une expression est contenue dans une liste d'autres expressions", "kbn-esql-validation-autocomplete.esql.definition.infoDoc": "Spécifier les modificateurs de tri des colonnes", "kbn-esql-validation-autocomplete.esql.definition.isNotNullDoc": "Prédicat pour la comparaison NULL : renvoie \"true\" si la valeur n'est pas NULL", "kbn-esql-validation-autocomplete.esql.definition.isNullDoc": "Prédicat pour la comparaison NULL : renvoie \"true\" si la valeur est NULL", "kbn-esql-validation-autocomplete.esql.definition.lessThanDoc": "Inférieur à", "kbn-esql-validation-autocomplete.esql.definition.lessThanOrEqualToDoc": "Inférieur ou égal à", - "kbn-esql-validation-autocomplete.esql.definition.likeDoc": "Filtrer les données en fonction des modèles de chaînes", "kbn-esql-validation-autocomplete.esql.definition.moduleDoc": "Module (%)", "kbn-esql-validation-autocomplete.esql.definition.multiplyDoc": "Multiplier (*)", "kbn-esql-validation-autocomplete.esql.definition.notDoc": "Non", "kbn-esql-validation-autocomplete.esql.definition.notEqualToDoc": "Différent de", "kbn-esql-validation-autocomplete.esql.definition.orDoc": "ou", - "kbn-esql-validation-autocomplete.esql.definition.rlikeDoc": "Filtrer les données en fonction des expressions régulières des chaînes", "kbn-esql-validation-autocomplete.esql.definition.subtractDoc": "Subtract (-)", "kbn-esql-validation-autocomplete.esql.definitions.abs": "Renvoie la valeur absolue.", "kbn-esql-validation-autocomplete.esql.definitions.acos": "Renvoie l'arc cosinus de `n` sous forme d'angle, exprimé en radians.", diff --git a/x-pack/platform/plugins/private/translations/translations/ja-JP.json b/x-pack/platform/plugins/private/translations/translations/ja-JP.json index 456d9878550bb..41c77fb9ff91f 100644 --- a/x-pack/platform/plugins/private/translations/translations/ja-JP.json +++ b/x-pack/platform/plugins/private/translations/translations/ja-JP.json @@ -5297,19 +5297,16 @@ "kbn-esql-validation-autocomplete.esql.definition.equalToDoc": "等しい", "kbn-esql-validation-autocomplete.esql.definition.greaterThanDoc": "より大きい", "kbn-esql-validation-autocomplete.esql.definition.greaterThanOrEqualToDoc": "よりも大きいまたは等しい", - "kbn-esql-validation-autocomplete.esql.definition.inDoc": "ある式が取る値が、他の式のリストに含まれているかどうかをテストします", "kbn-esql-validation-autocomplete.esql.definition.infoDoc": "列並べ替え修飾子を指定", "kbn-esql-validation-autocomplete.esql.definition.isNotNullDoc": "NULL比較の述部:値がNULLではない場合にTrueを返します", "kbn-esql-validation-autocomplete.esql.definition.isNullDoc": "NULL比較の述部:値がNULLである場合にTrueを返します", "kbn-esql-validation-autocomplete.esql.definition.lessThanDoc": "より小さい", "kbn-esql-validation-autocomplete.esql.definition.lessThanOrEqualToDoc": "以下", - "kbn-esql-validation-autocomplete.esql.definition.likeDoc": "文字列パターンに基づいてデータをフィルター", "kbn-esql-validation-autocomplete.esql.definition.moduleDoc": "モジュール(%)", "kbn-esql-validation-autocomplete.esql.definition.multiplyDoc": "乗算(*)", "kbn-esql-validation-autocomplete.esql.definition.notDoc": "NOT", "kbn-esql-validation-autocomplete.esql.definition.notEqualToDoc": "Not equal to", "kbn-esql-validation-autocomplete.esql.definition.orDoc": "または", - "kbn-esql-validation-autocomplete.esql.definition.rlikeDoc": "文字列の正規表現に基づいてデータをフィルター", "kbn-esql-validation-autocomplete.esql.definition.subtractDoc": "減算(-)", "kbn-esql-validation-autocomplete.esql.definitions.abs": "絶対値を返します。", "kbn-esql-validation-autocomplete.esql.definitions.acos": "nのアークコサインをラジアンで表記された角度として返します。", diff --git a/x-pack/platform/plugins/private/translations/translations/zh-CN.json b/x-pack/platform/plugins/private/translations/translations/zh-CN.json index 839a3d93a6cf7..f9e1d5408b20a 100644 --- a/x-pack/platform/plugins/private/translations/translations/zh-CN.json +++ b/x-pack/platform/plugins/private/translations/translations/zh-CN.json @@ -5264,19 +5264,16 @@ "kbn-esql-validation-autocomplete.esql.definition.equalToDoc": "等于", "kbn-esql-validation-autocomplete.esql.definition.greaterThanDoc": "大于", "kbn-esql-validation-autocomplete.esql.definition.greaterThanOrEqualToDoc": "大于或等于", - "kbn-esql-validation-autocomplete.esql.definition.inDoc": "测试某表达式接受的值是否包含在其他表达式列表中", "kbn-esql-validation-autocomplete.esql.definition.infoDoc": "指定列排序修饰符", "kbn-esql-validation-autocomplete.esql.definition.isNotNullDoc": "用于 NULL 比较的谓词:如果值不为 NULL,则返回 true", "kbn-esql-validation-autocomplete.esql.definition.isNullDoc": "用于 NULL 比较的谓词:如果值为 NULL,则返回 true", "kbn-esql-validation-autocomplete.esql.definition.lessThanDoc": "小于", "kbn-esql-validation-autocomplete.esql.definition.lessThanOrEqualToDoc": "小于或等于", - "kbn-esql-validation-autocomplete.esql.definition.likeDoc": "根据字符串模式筛选数据", "kbn-esql-validation-autocomplete.esql.definition.moduleDoc": "取余数 (%)", "kbn-esql-validation-autocomplete.esql.definition.multiplyDoc": "乘 (*)", "kbn-esql-validation-autocomplete.esql.definition.notDoc": "非", "kbn-esql-validation-autocomplete.esql.definition.notEqualToDoc": "不等于", "kbn-esql-validation-autocomplete.esql.definition.orDoc": "或", - "kbn-esql-validation-autocomplete.esql.definition.rlikeDoc": "根据字符串正则表达式筛选数据", "kbn-esql-validation-autocomplete.esql.definition.subtractDoc": "减 (-)", "kbn-esql-validation-autocomplete.esql.definitions.abs": "返回绝对值。", "kbn-esql-validation-autocomplete.esql.definitions.acos": "返回 `n` 的反余弦作为角度,以弧度表示。",