From f8e9e16d97a4181ff770137a22ca65a7672e6122 Mon Sep 17 00:00:00 2001 From: Quynh Nguyen Date: Wed, 13 Nov 2024 18:08:52 -0600 Subject: [PATCH 1/8] Update script for operators --- .../scripts/generate_function_definitions.ts | 12 +- .../src/definitions/generated/operators.ts | 3242 +++++++++++++++++ .../src/definitions/types.ts | 2 +- 3 files changed, 3253 insertions(+), 3 deletions(-) create mode 100644 packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts diff --git a/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts b/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts index fe2a85456aa12..c6ea8449e83ee 100644 --- a/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts +++ b/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts @@ -283,7 +283,7 @@ function getFunctionDefinition(ESFunctionDefinition: Record): Funct function printGeneratedFunctionsFile( functionDefinitions: FunctionDefinition[], - functionsType: 'aggregation' | 'scalar' + functionsType: 'aggregation' | 'scalar' | 'operators' ) { /** * Deals with asciidoc internal cross-references in the function descriptions @@ -406,13 +406,17 @@ 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); - + if (functionDefinition.type === 'operator') { + operatorDefinitions.push(functionDefinition); + } if (functionDefinition.type === 'eval') { scalarFunctionDefinitions.push(functionDefinition); } else if (functionDefinition.type === 'agg') { @@ -430,4 +434,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(operatorDefinitions, 'operators') + ); })(); diff --git a/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts b/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts new file mode 100644 index 0000000000000..ff22c64665d7e --- /dev/null +++ b/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts @@ -0,0 +1,3242 @@ +/* + * 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'; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const addDefinition: FunctionDefinition = { + type: 'operator', + name: 'add', + 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: 'lhs', + type: 'date', + optional: false, + }, + { + name: 'rhs', + type: 'date_period', + optional: false, + }, + ], + returnType: 'date', + }, + { + params: [ + { + name: 'lhs', + type: 'date', + optional: false, + }, + { + name: 'rhs', + type: 'time_duration', + optional: false, + }, + ], + returnType: 'date', + }, + { + params: [ + { + name: 'lhs', + type: 'date_period', + optional: false, + }, + { + name: 'rhs', + type: 'date', + optional: false, + }, + ], + returnType: 'date', + }, + { + params: [ + { + name: 'lhs', + type: 'date_period', + optional: false, + }, + { + name: 'rhs', + type: 'date_period', + optional: false, + }, + ], + returnType: 'date_period', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'integer', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'lhs', + type: 'time_duration', + optional: false, + }, + { + name: 'rhs', + type: 'date', + optional: false, + }, + ], + returnType: 'date', + }, + { + params: [ + { + name: 'lhs', + type: 'time_duration', + optional: false, + }, + { + name: 'rhs', + type: 'time_duration', + optional: false, + }, + ], + returnType: 'time_duration', + }, + { + params: [ + { + name: 'lhs', + type: 'unsigned_long', + optional: false, + }, + { + name: 'rhs', + type: 'unsigned_long', + optional: false, + }, + ], + returnType: 'unsigned_long', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics'], + supportedOptions: undefined, + validate: undefined, + examples: [], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const divDefinition: FunctionDefinition = { + type: 'operator', + name: 'div', + 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: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'integer', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'lhs', + type: 'unsigned_long', + optional: false, + }, + { + name: 'rhs', + type: 'unsigned_long', + optional: false, + }, + ], + returnType: 'unsigned_long', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics'], + supportedOptions: undefined, + validate: undefined, + examples: [], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const equalsDefinition: FunctionDefinition = { + type: 'operator', + name: 'equals', + 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: 'lhs', + type: 'boolean', + optional: false, + }, + { + name: 'rhs', + type: 'boolean', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'cartesian_point', + optional: false, + }, + { + name: 'rhs', + type: 'cartesian_point', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'cartesian_shape', + optional: false, + }, + { + name: 'rhs', + type: 'cartesian_shape', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'date', + optional: false, + }, + { + name: 'rhs', + type: 'date', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'geo_point', + optional: false, + }, + { + name: 'rhs', + type: 'geo_point', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'geo_shape', + optional: false, + }, + { + name: 'rhs', + type: 'geo_shape', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'ip', + optional: false, + }, + { + name: 'rhs', + type: 'ip', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'keyword', + optional: false, + }, + { + name: 'rhs', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'keyword', + optional: false, + }, + { + name: 'rhs', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'text', + optional: false, + }, + { + name: 'rhs', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'text', + optional: false, + }, + { + name: 'rhs', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'unsigned_long', + optional: false, + }, + { + name: 'rhs', + type: 'unsigned_long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'version', + optional: false, + }, + { + name: 'rhs', + type: 'version', + optional: false, + }, + ], + returnType: 'boolean', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics'], + supportedOptions: undefined, + validate: undefined, + examples: [], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const greaterThanDefinition: FunctionDefinition = { + type: 'operator', + name: 'greater_than', + 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: 'lhs', + type: 'date', + optional: false, + }, + { + name: 'rhs', + type: 'date', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'ip', + optional: false, + }, + { + name: 'rhs', + type: 'ip', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'keyword', + optional: false, + }, + { + name: 'rhs', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'keyword', + optional: false, + }, + { + name: 'rhs', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'text', + optional: false, + }, + { + name: 'rhs', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'text', + optional: false, + }, + { + name: 'rhs', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'unsigned_long', + optional: false, + }, + { + name: 'rhs', + type: 'unsigned_long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'version', + optional: false, + }, + { + name: 'rhs', + type: 'version', + optional: false, + }, + ], + returnType: 'boolean', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics'], + supportedOptions: undefined, + validate: undefined, + examples: [], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const greaterThanOrEqualDefinition: FunctionDefinition = { + type: 'operator', + name: 'greater_than_or_equal', + 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: 'lhs', + type: 'date', + optional: false, + }, + { + name: 'rhs', + type: 'date', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'ip', + optional: false, + }, + { + name: 'rhs', + type: 'ip', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'keyword', + optional: false, + }, + { + name: 'rhs', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'keyword', + optional: false, + }, + { + name: 'rhs', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'text', + optional: false, + }, + { + name: 'rhs', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'text', + optional: false, + }, + { + name: 'rhs', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'unsigned_long', + optional: false, + }, + { + name: 'rhs', + type: 'unsigned_long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'version', + optional: false, + }, + { + name: 'rhs', + type: 'version', + optional: false, + }, + ], + returnType: 'boolean', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics'], + supportedOptions: undefined, + validate: undefined, + examples: [], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const inDefinition: FunctionDefinition = { + type: 'operator', + 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: 'field', + type: 'boolean', + optional: false, + }, + { + name: 'inlist', + type: 'boolean', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'field', + type: 'cartesian_point', + optional: false, + }, + { + name: 'inlist', + type: 'cartesian_point', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'field', + type: 'cartesian_shape', + optional: false, + }, + { + name: 'inlist', + type: 'cartesian_shape', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'field', + type: 'double', + optional: false, + }, + { + name: 'inlist', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'field', + type: 'geo_point', + optional: false, + }, + { + name: 'inlist', + type: 'geo_point', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'field', + type: 'geo_shape', + optional: false, + }, + { + name: 'inlist', + type: 'geo_shape', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'field', + type: 'integer', + optional: false, + }, + { + name: 'inlist', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'field', + type: 'ip', + optional: false, + }, + { + name: 'inlist', + type: 'ip', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'field', + type: 'keyword', + optional: false, + }, + { + name: 'inlist', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'field', + type: 'keyword', + optional: false, + }, + { + name: 'inlist', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'field', + type: 'long', + optional: false, + }, + { + name: 'inlist', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'field', + type: 'text', + optional: false, + }, + { + name: 'inlist', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'field', + type: 'text', + optional: false, + }, + { + name: 'inlist', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'field', + type: 'version', + optional: false, + }, + { + name: 'inlist', + type: 'version', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics'], + 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: 'operator', + name: 'less_than', + 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: 'lhs', + type: 'date', + optional: false, + }, + { + name: 'rhs', + type: 'date', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'ip', + optional: false, + }, + { + name: 'rhs', + type: 'ip', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'keyword', + optional: false, + }, + { + name: 'rhs', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'keyword', + optional: false, + }, + { + name: 'rhs', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'text', + optional: false, + }, + { + name: 'rhs', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'text', + optional: false, + }, + { + name: 'rhs', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'unsigned_long', + optional: false, + }, + { + name: 'rhs', + type: 'unsigned_long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'version', + optional: false, + }, + { + name: 'rhs', + type: 'version', + optional: false, + }, + ], + returnType: 'boolean', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics'], + supportedOptions: undefined, + validate: undefined, + examples: [], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const lessThanOrEqualDefinition: FunctionDefinition = { + type: 'operator', + name: 'less_than_or_equal', + 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: 'lhs', + type: 'date', + optional: false, + }, + { + name: 'rhs', + type: 'date', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'ip', + optional: false, + }, + { + name: 'rhs', + type: 'ip', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'keyword', + optional: false, + }, + { + name: 'rhs', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'keyword', + optional: false, + }, + { + name: 'rhs', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'text', + optional: false, + }, + { + name: 'rhs', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'text', + optional: false, + }, + { + name: 'rhs', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'unsigned_long', + optional: false, + }, + { + name: 'rhs', + type: 'unsigned_long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'version', + optional: false, + }, + { + name: 'rhs', + type: 'version', + optional: false, + }, + ], + returnType: 'boolean', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics'], + supportedOptions: undefined, + validate: undefined, + examples: [], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const likeDefinition: FunctionDefinition = { + type: 'operator', + 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: 'text', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics'], + supportedOptions: undefined, + 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 modDefinition: FunctionDefinition = { + type: 'operator', + name: 'mod', + 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: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'integer', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'lhs', + type: 'unsigned_long', + optional: false, + }, + { + name: 'rhs', + type: 'unsigned_long', + optional: false, + }, + ], + returnType: 'unsigned_long', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics'], + supportedOptions: undefined, + validate: undefined, + examples: [], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const mulDefinition: FunctionDefinition = { + type: 'operator', + name: 'mul', + 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: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'integer', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'lhs', + type: 'unsigned_long', + optional: false, + }, + { + name: 'rhs', + type: 'unsigned_long', + optional: false, + }, + ], + returnType: 'unsigned_long', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics'], + supportedOptions: undefined, + validate: undefined, + examples: [], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const negDefinition: FunctionDefinition = { + type: 'operator', + name: 'neg', + description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.neg', { + defaultMessage: 'Returns the negation of the argument.', + }), + preview: false, + alias: undefined, + signatures: [ + { + params: [ + { + name: 'field', + type: 'date_period', + optional: false, + }, + ], + returnType: 'date_period', + }, + { + params: [ + { + name: 'field', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'field', + type: 'integer', + optional: false, + }, + ], + returnType: 'integer', + }, + { + params: [ + { + name: 'field', + type: 'long', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'field', + 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: 'operator', + name: 'not_equals', + 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: 'lhs', + type: 'boolean', + optional: false, + }, + { + name: 'rhs', + type: 'boolean', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'cartesian_point', + optional: false, + }, + { + name: 'rhs', + type: 'cartesian_point', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'cartesian_shape', + optional: false, + }, + { + name: 'rhs', + type: 'cartesian_shape', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'date', + optional: false, + }, + { + name: 'rhs', + type: 'date', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'geo_point', + optional: false, + }, + { + name: 'rhs', + type: 'geo_point', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'geo_shape', + optional: false, + }, + { + name: 'rhs', + type: 'geo_shape', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'ip', + optional: false, + }, + { + name: 'rhs', + type: 'ip', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'keyword', + optional: false, + }, + { + name: 'rhs', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'keyword', + optional: false, + }, + { + name: 'rhs', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'text', + optional: false, + }, + { + name: 'rhs', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'text', + optional: false, + }, + { + name: 'rhs', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'unsigned_long', + optional: false, + }, + { + name: 'rhs', + type: 'unsigned_long', + optional: false, + }, + ], + returnType: 'boolean', + }, + { + params: [ + { + name: 'lhs', + type: 'version', + optional: false, + }, + { + name: 'rhs', + type: 'version', + optional: false, + }, + ], + returnType: 'boolean', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics'], + supportedOptions: undefined, + validate: undefined, + examples: [], +}; + +// Do not edit this manually... generated by scripts/generate_function_definitions.ts +const rlikeDefinition: FunctionDefinition = { + type: 'operator', + 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: 'text', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics'], + supportedOptions: undefined, + 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: 'operator', + name: 'sub', + 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: 'lhs', + type: 'date', + optional: false, + }, + { + name: 'rhs', + type: 'date_period', + optional: false, + }, + ], + returnType: 'date', + }, + { + params: [ + { + name: 'lhs', + type: 'date', + optional: false, + }, + { + name: 'rhs', + type: 'time_duration', + optional: false, + }, + ], + returnType: 'date', + }, + { + params: [ + { + name: 'lhs', + type: 'date_period', + optional: false, + }, + { + name: 'rhs', + type: 'date_period', + optional: false, + }, + ], + returnType: 'date_period', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'lhs', + type: 'double', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'integer', + }, + { + params: [ + { + name: 'lhs', + type: 'integer', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'integer', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'lhs', + type: 'long', + optional: false, + }, + { + name: 'rhs', + type: 'long', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'lhs', + type: 'time_duration', + optional: false, + }, + { + name: 'rhs', + type: 'time_duration', + optional: false, + }, + ], + returnType: 'time_duration', + }, + { + params: [ + { + name: 'lhs', + type: 'unsigned_long', + optional: false, + }, + { + name: 'rhs', + type: 'unsigned_long', + optional: false, + }, + ], + returnType: 'unsigned_long', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics'], + supportedOptions: undefined, + validate: undefined, + examples: [], +}; +export const operatorsFunctionDefinitions = [ + addDefinition, + divDefinition, + equalsDefinition, + greaterThanDefinition, + greaterThanOrEqualDefinition, + inDefinition, + lessThanDefinition, + lessThanOrEqualDefinition, + likeDefinition, + modDefinition, + mulDefinition, + negDefinition, + notEqualsDefinition, + rlikeDefinition, + subDefinition, +]; diff --git a/packages/kbn-esql-validation-autocomplete/src/definitions/types.ts b/packages/kbn-esql-validation-autocomplete/src/definitions/types.ts index ff461683d8e76..7dcfc73137090 100644 --- a/packages/kbn-esql-validation-autocomplete/src/definitions/types.ts +++ b/packages/kbn-esql-validation-autocomplete/src/definitions/types.ts @@ -111,7 +111,7 @@ export const isReturnType = (str: string | FunctionParameterType): str is Functi (dataTypes.includes(str as SupportedDataType) || str === 'unknown' || str === 'any'); export interface FunctionDefinition { - type: 'builtin' | 'agg' | 'eval'; + type: 'builtin' | 'agg' | 'eval' | 'operator'; ignoreAsSuggestion?: boolean; name: string; alias?: string[]; From 0918b0acc2055339fd3d048bcff5956215bf829b Mon Sep 17 00:00:00 2001 From: Quynh Nguyen Date: Tue, 19 Nov 2024 14:19:36 -0600 Subject: [PATCH 2/8] Update script to automatically sync operators --- .../scripts/generate_function_definitions.ts | 103 +- .../src/definitions/builtin.ts | 10 +- .../src/definitions/generated/operators.ts | 6371 ++++++++--------- 3 files changed, 3282 insertions(+), 3202 deletions(-) diff --git a/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts b/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts index 289e4d284edab..cb8d24cfe44f3 100644 --- a/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts +++ b/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts @@ -299,6 +299,105 @@ function getFunctionDefinition(ESFunctionDefinition: Record): Funct return ret as FunctionDefinition; } +const operatorNames = { + add: '+', + sub: '-', + div: '/', + equals: '==', + greater_than: '>', + greater_than_or_equal: '>=', + less_than: '<', + less_than_or_equal: '<=', + not_equals: '!=', + mod: '%', + mul: '*', +}; +const validators: Record<'div' | 'mod', FunctionDefinition['validate']> = { + 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'; + default: + return str; + } +}; + +const enrichOperators = (operatorsFunctionDefinitions: FunctionDefinition[]) => { + return operatorsFunctionDefinitions.map((op) => ({ + ...op, + // alias: operatorNames[op.name] ?? op.name, + signatures: op.signatures.map((s) => ({ + ...s, + params: s.params.map((param) => ({ ...param, name: replaceParamName(param.name) })), + })), + ...(!Object.hasOwn(operatorNames, op.name) ? { ignoreAsSuggestion: /not/.test(op.name) } : {}), + // @TODO: change to operator type + type: 'builtin', + validate: validators[op.name], + })); +}; + function printGeneratedFunctionsFile( functionDefinitions: FunctionDefinition[], functionsType: 'aggregation' | 'scalar' | 'operators' @@ -348,7 +447,7 @@ function printGeneratedFunctionsFile( return `// Do not edit this manually... generated by scripts/generate_function_definitions.ts const ${getDefinitionName(name)}: FunctionDefinition = { type: '${type}', - name: '${name}', + name: '${operatorNames[name] ?? name}', description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.${name}', { defaultMessage: ${JSON.stringify( removeAsciiDocInternalCrossReferences(removeInlineAsciiDocLinks(description), functionNames) )} }),${functionDefinition.ignoreAsSuggestion ? 'ignoreAsSuggestion: true,\n' : ''} @@ -458,6 +557,6 @@ import { isLiteralItem } from '../../shared/helpers';` ); await writeFile( join(__dirname, '../src/definitions/generated/operators.ts'), - printGeneratedFunctionsFile(operatorDefinitions, 'operators') + printGeneratedFunctionsFile(enrichOperators(operatorDefinitions), 'operators') ); })(); diff --git a/packages/kbn-esql-validation-autocomplete/src/definitions/builtin.ts b/packages/kbn-esql-validation-autocomplete/src/definitions/builtin.ts index 954e9a0eb0b2c..625eb10f0ae7f 100644 --- a/packages/kbn-esql-validation-autocomplete/src/definitions/builtin.ts +++ b/packages/kbn-esql-validation-autocomplete/src/definitions/builtin.ts @@ -645,16 +645,8 @@ const otherDefinitions: FunctionDefinition[] = [ ]; export const builtinFunctions: FunctionDefinition[] = [ - ...mathFunctions, - ...comparisonFunctions, - ...likeFunctions, - ...inFunctions, + ...operatorsFunctionDefinitions, ...logicalOperators, ...nullFunctions, ...otherDefinitions, ]; - -// @TODO: remove -console.log(`--@@builtinFunctions`, builtinFunctions); -// @TODO: remove -console.log(`--@@operatorsFunctionDefinitions`, operatorsFunctionDefinitions); diff --git a/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts b/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts index ff22c64665d7e..10b2a0661ba47 100644 --- a/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts +++ b/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts @@ -1,12 +1,3 @@ -/* - * 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.__ * @@ -29,3214 +20,3212 @@ import { i18n } from '@kbn/i18n'; import type { FunctionDefinition } from '../types'; + + // Do not edit this manually... generated by scripts/generate_function_definitions.ts -const addDefinition: FunctionDefinition = { - type: 'operator', - name: 'add', - 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: 'lhs', - type: 'date', - optional: false, - }, - { - name: 'rhs', - type: 'date_period', - optional: false, - }, - ], - returnType: 'date', - }, - { - params: [ - { - name: 'lhs', - type: 'date', - optional: false, - }, - { - name: 'rhs', - type: 'time_duration', - optional: false, - }, - ], - returnType: 'date', - }, - { - params: [ - { - name: 'lhs', - type: 'date_period', - optional: false, - }, - { - name: 'rhs', - type: 'date', - optional: false, - }, - ], - returnType: 'date', - }, - { - params: [ - { - name: 'lhs', - type: 'date_period', - optional: false, - }, - { - name: 'rhs', - type: 'date_period', - optional: false, - }, - ], - returnType: 'date_period', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'double', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'double', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'double', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'double', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'integer', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'long', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'double', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'long', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'long', - }, - { - params: [ - { - name: 'lhs', - type: 'time_duration', - optional: false, - }, - { - name: 'rhs', - type: 'date', - optional: false, - }, - ], - returnType: 'date', - }, - { - params: [ - { - name: 'lhs', - type: 'time_duration', - optional: false, - }, - { - name: 'rhs', - type: 'time_duration', - optional: false, - }, - ], - returnType: 'time_duration', - }, - { - params: [ - { - name: 'lhs', - type: 'unsigned_long', - optional: false, - }, - { - name: 'rhs', - type: 'unsigned_long', - optional: false, - }, - ], - returnType: 'unsigned_long', - }, - ], - supportedCommands: ['stats', 'inlinestats', 'metrics'], - supportedOptions: undefined, - validate: undefined, - examples: [], -}; + 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_period", + "optional": false + }, + { + "name": "right", + "type": "date", + "optional": false + } + ], + "returnType": "date" + }, + { + "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": "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" + } +], + supportedCommands: ["stats","inlinestats","metrics"], + supportedOptions: undefined, + validate: undefined, + examples: [], +} // Do not edit this manually... generated by scripts/generate_function_definitions.ts -const divDefinition: FunctionDefinition = { - type: 'operator', - name: 'div', - 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: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'double', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'double', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'double', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'double', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'integer', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'long', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'double', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'long', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'long', - }, - { - params: [ - { - name: 'lhs', - type: 'unsigned_long', - optional: false, - }, - { - name: 'rhs', - type: 'unsigned_long', - optional: false, - }, - ], - returnType: 'unsigned_long', - }, - ], - supportedCommands: ['stats', 'inlinestats', 'metrics'], - supportedOptions: undefined, - validate: undefined, - examples: [], -}; + 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"], + supportedOptions: undefined, + 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: 'operator', - name: 'equals', - 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: 'lhs', - type: 'boolean', - optional: false, - }, - { - name: 'rhs', - type: 'boolean', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'cartesian_point', - optional: false, - }, - { - name: 'rhs', - type: 'cartesian_point', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'cartesian_shape', - optional: false, - }, - { - name: 'rhs', - type: 'cartesian_shape', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'date', - optional: false, - }, - { - name: 'rhs', - type: 'date', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'geo_point', - optional: false, - }, - { - name: 'rhs', - type: 'geo_point', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'geo_shape', - optional: false, - }, - { - name: 'rhs', - type: 'geo_shape', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'ip', - optional: false, - }, - { - name: 'rhs', - type: 'ip', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'keyword', - optional: false, - }, - { - name: 'rhs', - type: 'keyword', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'keyword', - optional: false, - }, - { - name: 'rhs', - type: 'text', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'text', - optional: false, - }, - { - name: 'rhs', - type: 'keyword', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'text', - optional: false, - }, - { - name: 'rhs', - type: 'text', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'unsigned_long', - optional: false, - }, - { - name: 'rhs', - type: 'unsigned_long', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'version', - optional: false, - }, - { - name: 'rhs', - type: 'version', - optional: false, - }, - ], - returnType: 'boolean', - }, - ], - supportedCommands: ['stats', 'inlinestats', 'metrics'], - supportedOptions: undefined, - validate: undefined, - examples: [], -}; + 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": "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" + } +], + supportedCommands: ["stats","inlinestats","metrics"], + supportedOptions: undefined, + validate: undefined, + examples: [], +} // Do not edit this manually... generated by scripts/generate_function_definitions.ts -const greaterThanDefinition: FunctionDefinition = { - type: 'operator', - name: 'greater_than', - 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: 'lhs', - type: 'date', - optional: false, - }, - { - name: 'rhs', - type: 'date', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'ip', - optional: false, - }, - { - name: 'rhs', - type: 'ip', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'keyword', - optional: false, - }, - { - name: 'rhs', - type: 'keyword', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'keyword', - optional: false, - }, - { - name: 'rhs', - type: 'text', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'text', - optional: false, - }, - { - name: 'rhs', - type: 'keyword', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'text', - optional: false, - }, - { - name: 'rhs', - type: 'text', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'unsigned_long', - optional: false, - }, - { - name: 'rhs', - type: 'unsigned_long', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'version', - optional: false, - }, - { - name: 'rhs', - type: 'version', - optional: false, - }, - ], - returnType: 'boolean', - }, - ], - supportedCommands: ['stats', 'inlinestats', 'metrics'], - supportedOptions: undefined, - validate: undefined, - examples: [], -}; + 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": "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"], + supportedOptions: undefined, + validate: undefined, + examples: [], +} // Do not edit this manually... generated by scripts/generate_function_definitions.ts -const greaterThanOrEqualDefinition: FunctionDefinition = { - type: 'operator', - name: 'greater_than_or_equal', - 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: 'lhs', - type: 'date', - optional: false, - }, - { - name: 'rhs', - type: 'date', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'ip', - optional: false, - }, - { - name: 'rhs', - type: 'ip', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'keyword', - optional: false, - }, - { - name: 'rhs', - type: 'keyword', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'keyword', - optional: false, - }, - { - name: 'rhs', - type: 'text', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'text', - optional: false, - }, - { - name: 'rhs', - type: 'keyword', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'text', - optional: false, - }, - { - name: 'rhs', - type: 'text', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'unsigned_long', - optional: false, - }, - { - name: 'rhs', - type: 'unsigned_long', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'version', - optional: false, - }, - { - name: 'rhs', - type: 'version', - optional: false, - }, - ], - returnType: 'boolean', - }, - ], - supportedCommands: ['stats', 'inlinestats', 'metrics'], - supportedOptions: undefined, - validate: undefined, - examples: [], -}; + 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": "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"], + supportedOptions: undefined, + validate: undefined, + examples: [], +} // Do not edit this manually... generated by scripts/generate_function_definitions.ts -const inDefinition: FunctionDefinition = { - type: 'operator', - 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: 'field', - type: 'boolean', - optional: false, - }, - { - name: 'inlist', - type: 'boolean', - optional: false, - }, - ], - returnType: 'boolean', - minParams: 2, - }, - { - params: [ - { - name: 'field', - type: 'cartesian_point', - optional: false, - }, - { - name: 'inlist', - type: 'cartesian_point', - optional: false, - }, - ], - returnType: 'boolean', - minParams: 2, - }, - { - params: [ - { - name: 'field', - type: 'cartesian_shape', - optional: false, - }, - { - name: 'inlist', - type: 'cartesian_shape', - optional: false, - }, - ], - returnType: 'boolean', - minParams: 2, - }, - { - params: [ - { - name: 'field', - type: 'double', - optional: false, - }, - { - name: 'inlist', - type: 'double', - optional: false, - }, - ], - returnType: 'boolean', - minParams: 2, - }, - { - params: [ - { - name: 'field', - type: 'geo_point', - optional: false, - }, - { - name: 'inlist', - type: 'geo_point', - optional: false, - }, - ], - returnType: 'boolean', - minParams: 2, - }, - { - params: [ - { - name: 'field', - type: 'geo_shape', - optional: false, - }, - { - name: 'inlist', - type: 'geo_shape', - optional: false, - }, - ], - returnType: 'boolean', - minParams: 2, - }, - { - params: [ - { - name: 'field', - type: 'integer', - optional: false, - }, - { - name: 'inlist', - type: 'integer', - optional: false, - }, - ], - returnType: 'boolean', - minParams: 2, - }, - { - params: [ - { - name: 'field', - type: 'ip', - optional: false, - }, - { - name: 'inlist', - type: 'ip', - optional: false, - }, - ], - returnType: 'boolean', - minParams: 2, - }, - { - params: [ - { - name: 'field', - type: 'keyword', - optional: false, - }, - { - name: 'inlist', - type: 'keyword', - optional: false, - }, - ], - returnType: 'boolean', - minParams: 2, - }, - { - params: [ - { - name: 'field', - type: 'keyword', - optional: false, - }, - { - name: 'inlist', - type: 'text', - optional: false, - }, - ], - returnType: 'boolean', - minParams: 2, - }, - { - params: [ - { - name: 'field', - type: 'long', - optional: false, - }, - { - name: 'inlist', - type: 'long', - optional: false, - }, - ], - returnType: 'boolean', - minParams: 2, - }, - { - params: [ - { - name: 'field', - type: 'text', - optional: false, - }, - { - name: 'inlist', - type: 'keyword', - optional: false, - }, - ], - returnType: 'boolean', - minParams: 2, - }, - { - params: [ - { - name: 'field', - type: 'text', - optional: false, - }, - { - name: 'inlist', - type: 'text', - optional: false, - }, - ], - returnType: 'boolean', - minParams: 2, - }, - { - params: [ - { - name: 'field', - type: 'version', - optional: false, - }, - { - name: 'inlist', - type: 'version', - optional: false, - }, - ], - returnType: 'boolean', - minParams: 2, - }, - ], - supportedCommands: ['stats', 'inlinestats', 'metrics'], - supportedOptions: undefined, - validate: undefined, - examples: ['ROW a = 1, b = 4, c = 3\n| WHERE c-a IN (3, b / 2, a)'], -}; + 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": "field", + "type": "boolean", + "optional": false + }, + { + "name": "inlist", + "type": "boolean", + "optional": false + } + ], + "returnType": "boolean", + "minParams": 2 + }, + { + "params": [ + { + "name": "field", + "type": "cartesian_point", + "optional": false + }, + { + "name": "inlist", + "type": "cartesian_point", + "optional": false + } + ], + "returnType": "boolean", + "minParams": 2 + }, + { + "params": [ + { + "name": "field", + "type": "cartesian_shape", + "optional": false + }, + { + "name": "inlist", + "type": "cartesian_shape", + "optional": false + } + ], + "returnType": "boolean", + "minParams": 2 + }, + { + "params": [ + { + "name": "field", + "type": "double", + "optional": false + }, + { + "name": "inlist", + "type": "double", + "optional": false + } + ], + "returnType": "boolean", + "minParams": 2 + }, + { + "params": [ + { + "name": "field", + "type": "geo_point", + "optional": false + }, + { + "name": "inlist", + "type": "geo_point", + "optional": false + } + ], + "returnType": "boolean", + "minParams": 2 + }, + { + "params": [ + { + "name": "field", + "type": "geo_shape", + "optional": false + }, + { + "name": "inlist", + "type": "geo_shape", + "optional": false + } + ], + "returnType": "boolean", + "minParams": 2 + }, + { + "params": [ + { + "name": "field", + "type": "integer", + "optional": false + }, + { + "name": "inlist", + "type": "integer", + "optional": false + } + ], + "returnType": "boolean", + "minParams": 2 + }, + { + "params": [ + { + "name": "field", + "type": "ip", + "optional": false + }, + { + "name": "inlist", + "type": "ip", + "optional": false + } + ], + "returnType": "boolean", + "minParams": 2 + }, + { + "params": [ + { + "name": "field", + "type": "keyword", + "optional": false + }, + { + "name": "inlist", + "type": "keyword", + "optional": false + } + ], + "returnType": "boolean", + "minParams": 2 + }, + { + "params": [ + { + "name": "field", + "type": "keyword", + "optional": false + }, + { + "name": "inlist", + "type": "text", + "optional": false + } + ], + "returnType": "boolean", + "minParams": 2 + }, + { + "params": [ + { + "name": "field", + "type": "long", + "optional": false + }, + { + "name": "inlist", + "type": "long", + "optional": false + } + ], + "returnType": "boolean", + "minParams": 2 + }, + { + "params": [ + { + "name": "field", + "type": "text", + "optional": false + }, + { + "name": "inlist", + "type": "keyword", + "optional": false + } + ], + "returnType": "boolean", + "minParams": 2 + }, + { + "params": [ + { + "name": "field", + "type": "text", + "optional": false + }, + { + "name": "inlist", + "type": "text", + "optional": false + } + ], + "returnType": "boolean", + "minParams": 2 + }, + { + "params": [ + { + "name": "field", + "type": "version", + "optional": false + }, + { + "name": "inlist", + "type": "version", + "optional": false + } + ], + "returnType": "boolean", + "minParams": 2 + } +], + supportedCommands: ["stats","inlinestats","metrics"], + 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: 'operator', - name: 'less_than', - 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: 'lhs', - type: 'date', - optional: false, - }, - { - name: 'rhs', - type: 'date', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'ip', - optional: false, - }, - { - name: 'rhs', - type: 'ip', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'keyword', - optional: false, - }, - { - name: 'rhs', - type: 'keyword', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'keyword', - optional: false, - }, - { - name: 'rhs', - type: 'text', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'text', - optional: false, - }, - { - name: 'rhs', - type: 'keyword', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'text', - optional: false, - }, - { - name: 'rhs', - type: 'text', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'unsigned_long', - optional: false, - }, - { - name: 'rhs', - type: 'unsigned_long', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'version', - optional: false, - }, - { - name: 'rhs', - type: 'version', - optional: false, - }, - ], - returnType: 'boolean', - }, - ], - supportedCommands: ['stats', 'inlinestats', 'metrics'], - supportedOptions: undefined, - validate: undefined, - examples: [], -}; + 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": "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"], + supportedOptions: undefined, + validate: undefined, + examples: [], +} // Do not edit this manually... generated by scripts/generate_function_definitions.ts -const lessThanOrEqualDefinition: FunctionDefinition = { - type: 'operator', - name: 'less_than_or_equal', - 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: 'lhs', - type: 'date', - optional: false, - }, - { - name: 'rhs', - type: 'date', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'ip', - optional: false, - }, - { - name: 'rhs', - type: 'ip', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'keyword', - optional: false, - }, - { - name: 'rhs', - type: 'keyword', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'keyword', - optional: false, - }, - { - name: 'rhs', - type: 'text', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'text', - optional: false, - }, - { - name: 'rhs', - type: 'keyword', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'text', - optional: false, - }, - { - name: 'rhs', - type: 'text', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'unsigned_long', - optional: false, - }, - { - name: 'rhs', - type: 'unsigned_long', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'version', - optional: false, - }, - { - name: 'rhs', - type: 'version', - optional: false, - }, - ], - returnType: 'boolean', - }, - ], - supportedCommands: ['stats', 'inlinestats', 'metrics'], - supportedOptions: undefined, - validate: undefined, - examples: [], -}; + 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": "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"], + supportedOptions: undefined, + validate: undefined, + examples: [], +} // Do not edit this manually... generated by scripts/generate_function_definitions.ts -const likeDefinition: FunctionDefinition = { - type: 'operator', - 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: 'text', - optional: false, - }, - ], - returnType: 'boolean', - minParams: 2, - }, - ], - supportedCommands: ['stats', 'inlinestats', 'metrics'], - supportedOptions: undefined, - validate: undefined, - examples: ['FROM employees\n| WHERE first_name LIKE """?b*"""\n| KEEP first_name, last_name'], -}; + 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": "text", + "optional": false + } + ], + "returnType": "boolean", + "minParams": 2 + } +], + supportedCommands: ["stats","inlinestats","metrics"], + supportedOptions: undefined, + 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 modDefinition: FunctionDefinition = { - type: 'operator', - name: 'mod', - 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: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'double', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'double', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'double', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'double', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'integer', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'long', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'double', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'long', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'long', - }, - { - params: [ - { - name: 'lhs', - type: 'unsigned_long', - optional: false, - }, - { - name: 'rhs', - type: 'unsigned_long', - optional: false, - }, - ], - returnType: 'unsigned_long', - }, - ], - supportedCommands: ['stats', 'inlinestats', 'metrics'], - supportedOptions: undefined, - validate: undefined, - examples: [], -}; + 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"], + supportedOptions: undefined, + 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: 'operator', - name: 'mul', - 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: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'double', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'double', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'double', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'double', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'integer', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'long', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'double', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'long', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'long', - }, - { - params: [ - { - name: 'lhs', - type: 'unsigned_long', - optional: false, - }, - { - name: 'rhs', - type: 'unsigned_long', - optional: false, - }, - ], - returnType: 'unsigned_long', - }, - ], - supportedCommands: ['stats', 'inlinestats', 'metrics'], - supportedOptions: undefined, - validate: undefined, - examples: [], -}; + 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"], + supportedOptions: undefined, + validate: undefined, + examples: [], +} // Do not edit this manually... generated by scripts/generate_function_definitions.ts -const negDefinition: FunctionDefinition = { - type: 'operator', - name: 'neg', - description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.neg', { - defaultMessage: 'Returns the negation of the argument.', - }), - preview: false, - alias: undefined, - signatures: [ - { - params: [ - { - name: 'field', - type: 'date_period', - optional: false, - }, - ], - returnType: 'date_period', - }, - { - params: [ - { - name: 'field', - type: 'double', - optional: false, - }, - ], - returnType: 'double', - }, - { - params: [ - { - name: 'field', - type: 'integer', - optional: false, - }, - ], - returnType: 'integer', - }, - { - params: [ - { - name: 'field', - type: 'long', - optional: false, - }, - ], - returnType: 'long', - }, - { - params: [ - { - name: 'field', - type: 'time_duration', - optional: false, - }, - ], - returnType: 'time_duration', - }, - ], - supportedCommands: ['stats', 'inlinestats', 'metrics'], - supportedOptions: undefined, - validate: undefined, - examples: [], -}; + const negDefinition: FunctionDefinition = { + type: 'builtin', + name: 'neg', + description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.neg', { defaultMessage: "Returns the negation of the argument." }), + preview: false, + alias: undefined, + signatures: [ + { + "params": [ + { + "name": "field", + "type": "date_period", + "optional": false + } + ], + "returnType": "date_period" + }, + { + "params": [ + { + "name": "field", + "type": "double", + "optional": false + } + ], + "returnType": "double" + }, + { + "params": [ + { + "name": "field", + "type": "integer", + "optional": false + } + ], + "returnType": "integer" + }, + { + "params": [ + { + "name": "field", + "type": "long", + "optional": false + } + ], + "returnType": "long" + }, + { + "params": [ + { + "name": "field", + "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: 'operator', - name: 'not_equals', - 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: 'lhs', - type: 'boolean', - optional: false, - }, - { - name: 'rhs', - type: 'boolean', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'cartesian_point', - optional: false, - }, - { - name: 'rhs', - type: 'cartesian_point', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'cartesian_shape', - optional: false, - }, - { - name: 'rhs', - type: 'cartesian_shape', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'date', - optional: false, - }, - { - name: 'rhs', - type: 'date', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'geo_point', - optional: false, - }, - { - name: 'rhs', - type: 'geo_point', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'geo_shape', - optional: false, - }, - { - name: 'rhs', - type: 'geo_shape', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'ip', - optional: false, - }, - { - name: 'rhs', - type: 'ip', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'keyword', - optional: false, - }, - { - name: 'rhs', - type: 'keyword', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'keyword', - optional: false, - }, - { - name: 'rhs', - type: 'text', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'text', - optional: false, - }, - { - name: 'rhs', - type: 'keyword', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'text', - optional: false, - }, - { - name: 'rhs', - type: 'text', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'unsigned_long', - optional: false, - }, - { - name: 'rhs', - type: 'unsigned_long', - optional: false, - }, - ], - returnType: 'boolean', - }, - { - params: [ - { - name: 'lhs', - type: 'version', - optional: false, - }, - { - name: 'rhs', - type: 'version', - optional: false, - }, - ], - returnType: 'boolean', - }, - ], - supportedCommands: ['stats', 'inlinestats', 'metrics'], - supportedOptions: undefined, - validate: undefined, - examples: [], -}; + 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": "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" + } +], + supportedCommands: ["stats","inlinestats","metrics"], + supportedOptions: undefined, + validate: undefined, + examples: [], +} // Do not edit this manually... generated by scripts/generate_function_definitions.ts -const rlikeDefinition: FunctionDefinition = { - type: 'operator', - 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: 'text', - optional: false, - }, - ], - returnType: 'boolean', - minParams: 2, - }, - ], - supportedCommands: ['stats', 'inlinestats', 'metrics'], - supportedOptions: undefined, - validate: undefined, - examples: [ - 'FROM employees\n| WHERE first_name RLIKE """.leja.*"""\n| KEEP first_name, last_name', - ], -}; + 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": "text", + "optional": false + } + ], + "returnType": "boolean", + "minParams": 2 + } +], + supportedCommands: ["stats","inlinestats","metrics"], + supportedOptions: undefined, + 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: 'operator', - name: 'sub', - 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: 'lhs', - type: 'date', - optional: false, - }, - { - name: 'rhs', - type: 'date_period', - optional: false, - }, - ], - returnType: 'date', - }, - { - params: [ - { - name: 'lhs', - type: 'date', - optional: false, - }, - { - name: 'rhs', - type: 'time_duration', - optional: false, - }, - ], - returnType: 'date', - }, - { - params: [ - { - name: 'lhs', - type: 'date_period', - optional: false, - }, - { - name: 'rhs', - type: 'date_period', - optional: false, - }, - ], - returnType: 'date_period', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'double', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'double', - }, - { - params: [ - { - name: 'lhs', - type: 'double', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'double', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'double', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'integer', - }, - { - params: [ - { - name: 'lhs', - type: 'integer', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'long', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'double', - optional: false, - }, - ], - returnType: 'double', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'integer', - optional: false, - }, - ], - returnType: 'long', - }, - { - params: [ - { - name: 'lhs', - type: 'long', - optional: false, - }, - { - name: 'rhs', - type: 'long', - optional: false, - }, - ], - returnType: 'long', - }, - { - params: [ - { - name: 'lhs', - type: 'time_duration', - optional: false, - }, - { - name: 'rhs', - type: 'time_duration', - optional: false, - }, - ], - returnType: 'time_duration', - }, - { - params: [ - { - name: 'lhs', - type: 'unsigned_long', - optional: false, - }, - { - name: 'rhs', - type: 'unsigned_long', - optional: false, - }, - ], - returnType: 'unsigned_long', - }, - ], - supportedCommands: ['stats', 'inlinestats', 'metrics'], - supportedOptions: undefined, - validate: undefined, - examples: [], -}; -export const operatorsFunctionDefinitions = [ - addDefinition, - divDefinition, - equalsDefinition, - greaterThanDefinition, - greaterThanOrEqualDefinition, - inDefinition, - lessThanDefinition, - lessThanOrEqualDefinition, - likeDefinition, - modDefinition, - mulDefinition, - negDefinition, - notEqualsDefinition, - rlikeDefinition, - subDefinition, -]; + 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_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": "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" + } +], + supportedCommands: ["stats","inlinestats","metrics"], + supportedOptions: undefined, + validate: undefined, + examples: [], +} + export const operatorsFunctionDefinitions = [addDefinition, +divDefinition, +equalsDefinition, +greaterThanDefinition, +greaterThanOrEqualDefinition, +inDefinition, +lessThanDefinition, +lessThanOrEqualDefinition, +likeDefinition, +modDefinition, +mulDefinition, +negDefinition, +notEqualsDefinition, +rlikeDefinition, +subDefinition]; \ No newline at end of file From 6a7cddef31b26ea33e062ecac75ed823c9c7f53d Mon Sep 17 00:00:00 2001 From: Quynh Nguyen Date: Tue, 19 Nov 2024 14:20:57 -0600 Subject: [PATCH 3/8] Update missing not_in, not_like, not_rlike --- .../src/definitions/builtin.ts | 21 +- .../src/definitions/generated/operators.ts | 6321 +++++++++-------- 2 files changed, 3193 insertions(+), 3149 deletions(-) diff --git a/packages/kbn-esql-validation-autocomplete/src/definitions/builtin.ts b/packages/kbn-esql-validation-autocomplete/src/definitions/builtin.ts index 625eb10f0ae7f..c6e441fd2592d 100644 --- a/packages/kbn-esql-validation-autocomplete/src/definitions/builtin.ts +++ b/packages/kbn-esql-validation-autocomplete/src/definitions/builtin.ts @@ -393,19 +393,7 @@ const likeFunctions: FunctionDefinition[] = [ // 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 = { @@ -451,13 +439,6 @@ const likeFunctions: FunctionDefinition[] = [ }); 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 @@ -646,6 +627,8 @@ const otherDefinitions: FunctionDefinition[] = [ export const builtinFunctions: FunctionDefinition[] = [ ...operatorsFunctionDefinitions, + ...inFunctions, + ...likeFunctions, ...logicalOperators, ...nullFunctions, ...otherDefinitions, diff --git a/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts b/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts index 10b2a0661ba47..1836cf20ce3c7 100644 --- a/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts +++ b/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts @@ -1,3 +1,12 @@ +/* + * 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.__ * @@ -20,425 +29,429 @@ import { i18n } from '@kbn/i18n'; import type { FunctionDefinition } from '../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_period", - "optional": false - }, - { - "name": "right", - "type": "date", - "optional": false - } - ], - "returnType": "date" - }, - { - "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": "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" - } -], - supportedCommands: ["stats","inlinestats","metrics"], - supportedOptions: undefined, - validate: undefined, - examples: [], -} +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_period', + optional: false, + }, + { + name: 'right', + type: 'date', + optional: false, + }, + ], + returnType: 'date', + }, + { + 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: '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', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics'], + supportedOptions: undefined, + 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"], - supportedOptions: undefined, - validate: (fnDef) => { +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'], + supportedOptions: undefined, + validate: (fnDef) => { const [left, right] = fnDef.args; const messages = []; if (!Array.isArray(left) && !Array.isArray(right)) { @@ -464,1882 +477,1912 @@ import type { FunctionDefinition } from '../types'; } return messages; }, - examples: [], -} + 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": "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" - } -], - supportedCommands: ["stats","inlinestats","metrics"], - supportedOptions: undefined, - validate: undefined, - examples: [], -} +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: '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', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics'], + supportedOptions: undefined, + 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": "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"], - supportedOptions: undefined, - validate: undefined, - examples: [], -} +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: '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'], + supportedOptions: undefined, + 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": "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"], - supportedOptions: undefined, - validate: undefined, - examples: [], -} +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: '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'], + supportedOptions: undefined, + 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": "field", - "type": "boolean", - "optional": false - }, - { - "name": "inlist", - "type": "boolean", - "optional": false - } - ], - "returnType": "boolean", - "minParams": 2 - }, - { - "params": [ - { - "name": "field", - "type": "cartesian_point", - "optional": false - }, - { - "name": "inlist", - "type": "cartesian_point", - "optional": false - } - ], - "returnType": "boolean", - "minParams": 2 - }, - { - "params": [ - { - "name": "field", - "type": "cartesian_shape", - "optional": false - }, - { - "name": "inlist", - "type": "cartesian_shape", - "optional": false - } - ], - "returnType": "boolean", - "minParams": 2 - }, - { - "params": [ - { - "name": "field", - "type": "double", - "optional": false - }, - { - "name": "inlist", - "type": "double", - "optional": false - } - ], - "returnType": "boolean", - "minParams": 2 - }, - { - "params": [ - { - "name": "field", - "type": "geo_point", - "optional": false - }, - { - "name": "inlist", - "type": "geo_point", - "optional": false - } - ], - "returnType": "boolean", - "minParams": 2 - }, - { - "params": [ - { - "name": "field", - "type": "geo_shape", - "optional": false - }, - { - "name": "inlist", - "type": "geo_shape", - "optional": false - } - ], - "returnType": "boolean", - "minParams": 2 - }, - { - "params": [ - { - "name": "field", - "type": "integer", - "optional": false - }, - { - "name": "inlist", - "type": "integer", - "optional": false - } - ], - "returnType": "boolean", - "minParams": 2 - }, - { - "params": [ - { - "name": "field", - "type": "ip", - "optional": false - }, - { - "name": "inlist", - "type": "ip", - "optional": false - } - ], - "returnType": "boolean", - "minParams": 2 - }, - { - "params": [ - { - "name": "field", - "type": "keyword", - "optional": false - }, - { - "name": "inlist", - "type": "keyword", - "optional": false - } - ], - "returnType": "boolean", - "minParams": 2 - }, - { - "params": [ - { - "name": "field", - "type": "keyword", - "optional": false - }, - { - "name": "inlist", - "type": "text", - "optional": false - } - ], - "returnType": "boolean", - "minParams": 2 - }, - { - "params": [ - { - "name": "field", - "type": "long", - "optional": false - }, - { - "name": "inlist", - "type": "long", - "optional": false - } - ], - "returnType": "boolean", - "minParams": 2 - }, - { - "params": [ - { - "name": "field", - "type": "text", - "optional": false - }, - { - "name": "inlist", - "type": "keyword", - "optional": false - } - ], - "returnType": "boolean", - "minParams": 2 - }, - { - "params": [ - { - "name": "field", - "type": "text", - "optional": false - }, - { - "name": "inlist", - "type": "text", - "optional": false - } - ], - "returnType": "boolean", - "minParams": 2 - }, - { - "params": [ - { - "name": "field", - "type": "version", - "optional": false - }, - { - "name": "inlist", - "type": "version", - "optional": false - } - ], - "returnType": "boolean", - "minParams": 2 - } -], - supportedCommands: ["stats","inlinestats","metrics"], - supportedOptions: undefined, - validate: undefined, - examples: ["ROW a = 1, b = 4, c = 3\n| WHERE c-a IN (3, b / 2, a)"], -} +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: 'field', + type: 'boolean', + optional: false, + }, + { + name: 'inlist', + type: 'boolean', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'field', + type: 'cartesian_point', + optional: false, + }, + { + name: 'inlist', + type: 'cartesian_point', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'field', + type: 'cartesian_shape', + optional: false, + }, + { + name: 'inlist', + type: 'cartesian_shape', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'field', + type: 'double', + optional: false, + }, + { + name: 'inlist', + type: 'double', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'field', + type: 'geo_point', + optional: false, + }, + { + name: 'inlist', + type: 'geo_point', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'field', + type: 'geo_shape', + optional: false, + }, + { + name: 'inlist', + type: 'geo_shape', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'field', + type: 'integer', + optional: false, + }, + { + name: 'inlist', + type: 'integer', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'field', + type: 'ip', + optional: false, + }, + { + name: 'inlist', + type: 'ip', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'field', + type: 'keyword', + optional: false, + }, + { + name: 'inlist', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'field', + type: 'keyword', + optional: false, + }, + { + name: 'inlist', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'field', + type: 'long', + optional: false, + }, + { + name: 'inlist', + type: 'long', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'field', + type: 'text', + optional: false, + }, + { + name: 'inlist', + type: 'keyword', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'field', + type: 'text', + optional: false, + }, + { + name: 'inlist', + type: 'text', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + { + params: [ + { + name: 'field', + type: 'version', + optional: false, + }, + { + name: 'inlist', + type: 'version', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics'], + 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": "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"], - supportedOptions: undefined, - validate: undefined, - examples: [], -} +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: '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'], + supportedOptions: undefined, + 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": "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"], - supportedOptions: undefined, - validate: undefined, - examples: [], -} +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: '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'], + supportedOptions: undefined, + 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": "text", - "optional": false - } - ], - "returnType": "boolean", - "minParams": 2 - } -], - supportedCommands: ["stats","inlinestats","metrics"], - supportedOptions: undefined, - validate: undefined, - examples: ["FROM employees\n| WHERE first_name LIKE \"\"\"?b*\"\"\"\n| KEEP first_name, last_name"], -} +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: 'text', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics'], + supportedOptions: undefined, + 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 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"], - supportedOptions: undefined, - validate: (fnDef) => { +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'], + supportedOptions: undefined, + validate: (fnDef) => { const [left, right] = fnDef.args; const messages = []; if (!Array.isArray(left) && !Array.isArray(right)) { @@ -2365,867 +2408,885 @@ import type { FunctionDefinition } from '../types'; } return messages; }, - examples: [], -} + 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"], - supportedOptions: undefined, - validate: undefined, - examples: [], -} +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'], + supportedOptions: undefined, + validate: undefined, + examples: [], +}; // Do not edit this manually... generated by scripts/generate_function_definitions.ts - const negDefinition: FunctionDefinition = { - type: 'builtin', - name: 'neg', - description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.neg', { defaultMessage: "Returns the negation of the argument." }), - preview: false, - alias: undefined, - signatures: [ - { - "params": [ - { - "name": "field", - "type": "date_period", - "optional": false - } - ], - "returnType": "date_period" - }, - { - "params": [ - { - "name": "field", - "type": "double", - "optional": false - } - ], - "returnType": "double" - }, - { - "params": [ - { - "name": "field", - "type": "integer", - "optional": false - } - ], - "returnType": "integer" - }, - { - "params": [ - { - "name": "field", - "type": "long", - "optional": false - } - ], - "returnType": "long" - }, - { - "params": [ - { - "name": "field", - "type": "time_duration", - "optional": false - } - ], - "returnType": "time_duration" - } -], - supportedCommands: ["stats","inlinestats","metrics"], - supportedOptions: undefined, - validate: undefined, - examples: [], -} +const negDefinition: FunctionDefinition = { + type: 'builtin', + name: 'neg', + description: i18n.translate('kbn-esql-validation-autocomplete.esql.definitions.neg', { + defaultMessage: 'Returns the negation of the argument.', + }), + preview: false, + alias: undefined, + signatures: [ + { + params: [ + { + name: 'field', + type: 'date_period', + optional: false, + }, + ], + returnType: 'date_period', + }, + { + params: [ + { + name: 'field', + type: 'double', + optional: false, + }, + ], + returnType: 'double', + }, + { + params: [ + { + name: 'field', + type: 'integer', + optional: false, + }, + ], + returnType: 'integer', + }, + { + params: [ + { + name: 'field', + type: 'long', + optional: false, + }, + ], + returnType: 'long', + }, + { + params: [ + { + name: 'field', + 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": "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" - } -], - supportedCommands: ["stats","inlinestats","metrics"], - supportedOptions: undefined, - validate: undefined, - examples: [], -} +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: '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', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics'], + 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": "text", - "optional": false - } - ], - "returnType": "boolean", - "minParams": 2 - } -], - supportedCommands: ["stats","inlinestats","metrics"], - supportedOptions: undefined, - validate: undefined, - examples: ["FROM employees\n| WHERE first_name RLIKE \"\"\".leja.*\"\"\"\n| KEEP first_name, last_name"], -} +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: 'text', + optional: false, + }, + ], + returnType: 'boolean', + minParams: 2, + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics'], + supportedOptions: undefined, + 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_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": "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" - } -], - supportedCommands: ["stats","inlinestats","metrics"], - supportedOptions: undefined, - validate: undefined, - examples: [], -} - export const operatorsFunctionDefinitions = [addDefinition, -divDefinition, -equalsDefinition, -greaterThanDefinition, -greaterThanOrEqualDefinition, -inDefinition, -lessThanDefinition, -lessThanOrEqualDefinition, -likeDefinition, -modDefinition, -mulDefinition, -negDefinition, -notEqualsDefinition, -rlikeDefinition, -subDefinition]; \ No newline at end of file +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_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: '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', + }, + ], + supportedCommands: ['stats', 'inlinestats', 'metrics'], + supportedOptions: undefined, + validate: undefined, + examples: [], +}; +export const operatorsFunctionDefinitions = [ + addDefinition, + divDefinition, + equalsDefinition, + greaterThanDefinition, + greaterThanOrEqualDefinition, + inDefinition, + lessThanDefinition, + lessThanOrEqualDefinition, + likeDefinition, + modDefinition, + mulDefinition, + negDefinition, + notEqualsDefinition, + rlikeDefinition, + subDefinition, +]; From 41f7ea35fcbd513d83fa8cf1ea64580c85495007 Mon Sep 17 00:00:00 2001 From: Quynh Nguyen Date: Tue, 19 Nov 2024 14:39:06 -0600 Subject: [PATCH 4/8] Update script --- .../scripts/generate_function_definitions.ts | 38 +++++++++++++------ .../src/definitions/builtin.ts | 12 +++--- .../src/definitions/generated/operators.ts | 22 ++++++----- 3 files changed, 44 insertions(+), 28 deletions(-) diff --git a/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts b/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts index cb8d24cfe44f3..dff25914d20ad 100644 --- a/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts +++ b/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts @@ -384,18 +384,26 @@ const replaceParamName = (str: string) => { }; const enrichOperators = (operatorsFunctionDefinitions: FunctionDefinition[]) => { - return operatorsFunctionDefinitions.map((op) => ({ - ...op, - // alias: operatorNames[op.name] ?? op.name, - signatures: op.signatures.map((s) => ({ - ...s, - params: s.params.map((param) => ({ ...param, name: replaceParamName(param.name) })), - })), - ...(!Object.hasOwn(operatorNames, op.name) ? { ignoreAsSuggestion: /not/.test(op.name) } : {}), - // @TODO: change to operator type - type: 'builtin', - validate: validators[op.name], - })); + return operatorsFunctionDefinitions.map((op) => { + const isMathOperator = ['add', 'sub', 'div', 'mod', 'mul'].includes(op.name); + return { + ...op, + 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) })), + })), + // Elasticsearch docs does not include the full supported commands for math operators + // so we are overriding to add proper support + supportedCommands: isMathOperator + ? ['eval', 'where', 'row', 'stats', 'metrics', 'sort'] + : op.supportedCommands, + supportedOptions: isMathOperator ? ['by'] : op.supportedOptions, + // @TODO: change to operator type + type: 'builtin', + validate: validators[op.name], + }; + }); }; function printGeneratedFunctionsFile( @@ -488,6 +496,12 @@ ${ import { isLiteralItem } from '../../shared/helpers';` : '' } +${ + functionsType === 'operators' + ? `import type { isNumericType } from '../../shared/esql_types';` + : '' +} + `; diff --git a/packages/kbn-esql-validation-autocomplete/src/definitions/builtin.ts b/packages/kbn-esql-validation-autocomplete/src/definitions/builtin.ts index c6e441fd2592d..0292f70d2911b 100644 --- a/packages/kbn-esql-validation-autocomplete/src/definitions/builtin.ts +++ b/packages/kbn-esql-validation-autocomplete/src/definitions/builtin.ts @@ -384,7 +384,7 @@ export const comparisonFunctions: FunctionDefinition[] = [ }, ].map((op): FunctionDefinition => createComparisonDefinition(op)); -const likeFunctions: FunctionDefinition[] = [ +const notLikeFunctions: FunctionDefinition[] = [ // Skip the insensitive case equality until it gets restored back // new special comparison operator for strings only // { @@ -398,7 +398,7 @@ const likeFunctions: FunctionDefinition[] = [ ].map(({ name, description }) => { const def: FunctionDefinition = { type: 'builtin' as const, - ignoreAsSuggestion: /not/.test(name), + ignoreAsSuggestion: true, name, description, supportedCommands: ['eval', 'where', 'row', 'sort'], @@ -438,7 +438,7 @@ const likeFunctions: FunctionDefinition[] = [ return def; }); -const inFunctions: FunctionDefinition[] = [ +const notInFunctions: FunctionDefinition[] = [ { name: 'not_in', description: '' }, ].map(({ name, description }) => ({ // set all arrays to type "any" for now @@ -451,7 +451,7 @@ const inFunctions: FunctionDefinition[] = [ // // we need to revisit with more robust validation type: 'builtin', - ignoreAsSuggestion: /not/.test(name), + ignoreAsSuggestion: true, name, description, supportedCommands: ['eval', 'where', 'row', 'sort'], @@ -627,8 +627,8 @@ const otherDefinitions: FunctionDefinition[] = [ export const builtinFunctions: FunctionDefinition[] = [ ...operatorsFunctionDefinitions, - ...inFunctions, - ...likeFunctions, + ...notInFunctions, + ...notLikeFunctions, ...logicalOperators, ...nullFunctions, ...otherDefinitions, diff --git a/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts b/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts index 1836cf20ce3c7..7dc7810dfb88b 100644 --- a/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts +++ b/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts @@ -29,6 +29,8 @@ import { i18n } from '@kbn/i18n'; import type { FunctionDefinition } from '../types'; +import type { isNumericType } from '../../shared/esql_types'; + // Do not edit this manually... generated by scripts/generate_function_definitions.ts const addDefinition: FunctionDefinition = { type: 'builtin', @@ -281,8 +283,8 @@ const addDefinition: FunctionDefinition = { returnType: 'unsigned_long', }, ], - supportedCommands: ['stats', 'inlinestats', 'metrics'], - supportedOptions: undefined, + supportedCommands: ['eval', 'where', 'row', 'stats', 'metrics', 'sort'], + supportedOptions: ['by'], validate: undefined, examples: [], }; @@ -449,8 +451,8 @@ const divDefinition: FunctionDefinition = { returnType: 'unsigned_long', }, ], - supportedCommands: ['stats', 'inlinestats', 'metrics'], - supportedOptions: undefined, + supportedCommands: ['eval', 'where', 'row', 'stats', 'metrics', 'sort'], + supportedOptions: ['by'], validate: (fnDef) => { const [left, right] = fnDef.args; const messages = []; @@ -2380,8 +2382,8 @@ const modDefinition: FunctionDefinition = { returnType: 'unsigned_long', }, ], - supportedCommands: ['stats', 'inlinestats', 'metrics'], - supportedOptions: undefined, + supportedCommands: ['eval', 'where', 'row', 'stats', 'metrics', 'sort'], + supportedOptions: ['by'], validate: (fnDef) => { const [left, right] = fnDef.args; const messages = []; @@ -2573,8 +2575,8 @@ const mulDefinition: FunctionDefinition = { returnType: 'unsigned_long', }, ], - supportedCommands: ['stats', 'inlinestats', 'metrics'], - supportedOptions: undefined, + supportedCommands: ['eval', 'where', 'row', 'stats', 'metrics', 'sort'], + supportedOptions: ['by'], validate: undefined, examples: [], }; @@ -3268,8 +3270,8 @@ const subDefinition: FunctionDefinition = { returnType: 'unsigned_long', }, ], - supportedCommands: ['stats', 'inlinestats', 'metrics'], - supportedOptions: undefined, + supportedCommands: ['eval', 'where', 'row', 'stats', 'metrics', 'sort'], + supportedOptions: ['by'], validate: undefined, examples: [], }; From 4f1e6477385560fbdf0f8116dde400e044985156 Mon Sep 17 00:00:00 2001 From: Quynh Nguyen Date: Tue, 19 Nov 2024 15:07:10 -0600 Subject: [PATCH 5/8] Update scripts --- .../scripts/generate_function_definitions.ts | 147 ++++++- .../src/definitions/generated/operators.ts | 389 +++++++++++++++++- 2 files changed, 507 insertions(+), 29 deletions(-) diff --git a/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts b/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts index dff25914d20ad..d3308b136e717 100644 --- a/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts +++ b/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts @@ -299,6 +299,109 @@ 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 = { + add: { name: '+', isMathOperator: true, isComparisonOperator: false }, + sub: { name: '-', isMathOperator: true, isComparisonOperator: false }, + 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 }, +}; + const operatorNames = { add: '+', sub: '-', @@ -385,20 +488,38 @@ const replaceParamName = (str: string) => { const enrichOperators = (operatorsFunctionDefinitions: FunctionDefinition[]) => { return operatorsFunctionDefinitions.map((op) => { - const isMathOperator = ['add', 'sub', 'div', 'mod', 'mul'].includes(op.name); + const isMathOperator = op.name in operatorsMeta && operatorsMeta[op.name]?.isMathOperator; + const isComparisonOperator = + op.name in operatorsMeta && operatorsMeta[op.name]?.isComparisonOperator; + + const 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 = ['eval', 'where', 'row', 'sort']; + supportedOptions = ['by']; + } + if (isMathOperator) { + supportedCommands = ['eval', 'where', 'row', 'stats', 'metrics', 'sort']; + supportedOptions = ['by']; + } + if (operatorsMeta[op.name] && operatorsMeta[op.name]?.extraSignatures) { + signatures.push(...operatorsMeta[op.name].extraSignatures); + } + + const description = operatorsMeta[op.name]?.description ?? op.description; return { ...op, - 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) })), - })), + description, + signatures, // Elasticsearch docs does not include the full supported commands for math operators // so we are overriding to add proper support - supportedCommands: isMathOperator - ? ['eval', 'where', 'row', 'stats', 'metrics', 'sort'] - : op.supportedCommands, - supportedOptions: isMathOperator ? ['by'] : op.supportedOptions, + supportedCommands, + supportedOptions, // @TODO: change to operator type type: 'builtin', validate: validators[op.name], @@ -496,11 +617,7 @@ ${ import { isLiteralItem } from '../../shared/helpers';` : '' } -${ - functionsType === 'operators' - ? `import type { isNumericType } from '../../shared/esql_types';` - : '' -} +${functionsType === 'operators' ? `import { isNumericType } from '../../shared/esql_types';` : ''} diff --git a/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts b/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts index 7dc7810dfb88b..c30ef20a4fed4 100644 --- a/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts +++ b/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts @@ -28,8 +28,7 @@ import { i18n } from '@kbn/i18n'; import type { FunctionDefinition } from '../types'; - -import type { isNumericType } from '../../shared/esql_types'; +import { isNumericType } from '../../shared/esql_types'; // Do not edit this manually... generated by scripts/generate_function_definitions.ts const addDefinition: FunctionDefinition = { @@ -823,9 +822,106 @@ const equalsDefinition: FunctionDefinition = { ], 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'], - supportedOptions: undefined, + supportedCommands: ['eval', 'where', 'row', 'sort'], + supportedOptions: ['by'], validate: undefined, examples: [], }; @@ -1096,9 +1192,65 @@ const greaterThanDefinition: FunctionDefinition = { ], 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'], - supportedOptions: undefined, + supportedCommands: ['eval', 'where', 'row', 'sort'], + supportedOptions: ['by'], validate: undefined, examples: [], }; @@ -1372,9 +1524,65 @@ const greaterThanOrEqualDefinition: FunctionDefinition = { ], 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'], - supportedOptions: undefined, + supportedCommands: ['eval', 'where', 'row', 'sort'], + supportedOptions: ['by'], validate: undefined, examples: [], }; @@ -1887,9 +2095,65 @@ const lessThanDefinition: FunctionDefinition = { ], 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'], - supportedOptions: undefined, + supportedCommands: ['eval', 'where', 'row', 'sort'], + supportedOptions: ['by'], validate: undefined, examples: [], }; @@ -2164,8 +2428,8 @@ const lessThanOrEqualDefinition: FunctionDefinition = { returnType: 'boolean', }, ], - supportedCommands: ['stats', 'inlinestats', 'metrics'], - supportedOptions: undefined, + supportedCommands: ['eval', 'where', 'row', 'sort'], + supportedOptions: ['by'], validate: undefined, examples: [], }; @@ -2989,9 +3253,106 @@ const notEqualsDefinition: FunctionDefinition = { ], 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'], - supportedOptions: undefined, + supportedCommands: ['eval', 'where', 'row', 'sort'], + supportedOptions: ['by'], validate: undefined, examples: [], }; From ebf02118e9bfed00535a1440626786a3855a9a77 Mon Sep 17 00:00:00 2001 From: Quynh Nguyen Date: Tue, 19 Nov 2024 22:39:15 -0600 Subject: [PATCH 6/8] Update types --- .../scripts/generate_function_definitions.ts | 37 +++++--- .../src/definitions/types.ts | 84 ++++++++++--------- 2 files changed, 68 insertions(+), 53 deletions(-) diff --git a/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts b/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts index d3308b136e717..4386b7655b844 100644 --- a/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts +++ b/packages/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, Signature } from '../src/definitions/types'; import { FULL_TEXT_SEARCH_FUNCTIONS } from '../src/shared/constants'; const aliasTable: Record = { to_version: ['to_ver'], @@ -315,7 +315,15 @@ const comparisonOperatorSignatures = (['ip', 'version'] as const).flatMap((type) returnType: 'boolean' as const, }, ]); -const operatorsMeta = { +const operatorsMeta: Record< + string, + { + name: string; + isMathOperator: boolean; + isComparisonOperator: boolean; + extraSignatures?: Signature[]; + } +> = { add: { name: '+', isMathOperator: true, isComparisonOperator: false }, sub: { name: '-', isMathOperator: true, isComparisonOperator: false }, div: { name: '/', isMathOperator: true, isComparisonOperator: false }, @@ -402,7 +410,7 @@ const operatorsMeta = { mul: { name: '*', isMathOperator: true, isComparisonOperator: false }, }; -const operatorNames = { +const operatorNames: Record = { add: '+', sub: '-', div: '/', @@ -415,7 +423,7 @@ const operatorNames = { mod: '%', mul: '*', }; -const validators: Record<'div' | 'mod', FunctionDefinition['validate']> = { +const validators: Record = { div: `(fnDef) => { const [left, right] = fnDef.args; const messages = []; @@ -486,11 +494,15 @@ const replaceParamName = (str: string) => { } }; -const enrichOperators = (operatorsFunctionDefinitions: FunctionDefinition[]) => { +const enrichOperators = ( + operatorsFunctionDefinitions: FunctionDefinition[] +): FunctionDefinition[] => { + // @ts-expect-error Stringified version of the validator function return operatorsFunctionDefinitions.map((op) => { - const isMathOperator = op.name in operatorsMeta && operatorsMeta[op.name]?.isMathOperator; + const isMathOperator = + Object.hasOwn(operatorsMeta, op.name) && operatorsMeta[op.name]?.isMathOperator; const isComparisonOperator = - op.name in operatorsMeta && operatorsMeta[op.name]?.isComparisonOperator; + Object.hasOwn(operatorsMeta, op.name) && operatorsMeta[op.name]?.isComparisonOperator; const signatures = op.signatures.map((s) => ({ ...s, @@ -507,21 +519,22 @@ const enrichOperators = (operatorsFunctionDefinitions: FunctionDefinition[]) => supportedCommands = ['eval', 'where', 'row', 'stats', 'metrics', 'sort']; supportedOptions = ['by']; } - if (operatorsMeta[op.name] && operatorsMeta[op.name]?.extraSignatures) { - signatures.push(...operatorsMeta[op.name].extraSignatures); + if ( + Object.hasOwn(operatorsMeta, op.name) && + Array.isArray(operatorsMeta[op.name]?.extraSignatures) + ) { + signatures.push(...(operatorsMeta[op.name].extraSignatures ?? [])); } - const description = operatorsMeta[op.name]?.description ?? op.description; return { ...op, - description, 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', + type: 'builtin' as const, validate: validators[op.name], }; }); diff --git a/packages/kbn-esql-validation-autocomplete/src/definitions/types.ts b/packages/kbn-esql-validation-autocomplete/src/definitions/types.ts index f44b84687e28a..e45379607b0df 100644 --- a/packages/kbn-esql-validation-autocomplete/src/definitions/types.ts +++ b/packages/kbn-esql-validation-autocomplete/src/definitions/types.ts @@ -117,6 +117,48 @@ 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' | 'operator'; preview?: boolean; @@ -126,47 +168,7 @@ 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[]; } From 4f6c9e984163f240c7f10a66c8aae16b38a7e0b5 Mon Sep 17 00:00:00 2001 From: Quynh Nguyen Date: Wed, 20 Nov 2024 09:40:04 -0600 Subject: [PATCH 7/8] Update math function failures --- .../scripts/generate_function_definitions.ts | 61 ++- .../src/definitions/generated/operators.ts | 77 +++- .../esql_validation_meta_tests.json | 361 +++--------------- .../src/validation/validation.test.ts | 8 +- 4 files changed, 172 insertions(+), 335 deletions(-) diff --git a/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts b/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts index 4386b7655b844..fd56f5399d121 100644 --- a/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts +++ b/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts @@ -324,8 +324,48 @@ const operatorsMeta: Record< extraSignatures?: Signature[]; } > = { - add: { name: '+', isMathOperator: true, isComparisonOperator: false }, - sub: { name: '-', isMathOperator: true, isComparisonOperator: false }, + 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: '==', @@ -504,6 +544,8 @@ const enrichOperators = ( const isComparisonOperator = Object.hasOwn(operatorsMeta, op.name) && operatorsMeta[op.name]?.isComparisonOperator; + const isInOperator = op.name === 'in'; + const signatures = op.signatures.map((s) => ({ ...s, // Elasticsearch docs uses lhs and rhs instead of left and right that Kibana code uses @@ -512,13 +554,24 @@ const enrichOperators = ( let supportedCommands = op.supportedCommands; let supportedOptions = op.supportedOptions; if (isComparisonOperator) { - supportedCommands = ['eval', 'where', 'row', 'sort']; + supportedCommands = _.uniq([...op.supportedCommands, 'eval', 'where', 'row', 'sort']); supportedOptions = ['by']; } if (isMathOperator) { - supportedCommands = ['eval', 'where', 'row', 'stats', 'metrics', 'sort']; + supportedCommands = _.uniq([ + ...op.supportedCommands, + 'eval', + 'where', + 'row', + 'stats', + 'metrics', + 'sort', + ]); supportedOptions = ['by']; } + if (isInOperator) { + supportedCommands = _.uniq([...op.supportedCommands, 'eval', 'where', 'row', 'sort']); + } if ( Object.hasOwn(operatorsMeta, op.name) && Array.isArray(operatorsMeta[op.name]?.extraSignatures) diff --git a/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts b/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts index c30ef20a4fed4..4eb8851879fb4 100644 --- a/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts +++ b/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts @@ -28,6 +28,7 @@ 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 @@ -281,8 +282,34 @@ const addDefinition: FunctionDefinition = { ], 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: ['eval', 'where', 'row', 'stats', 'metrics', 'sort'], + supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'], supportedOptions: ['by'], validate: undefined, examples: [], @@ -450,7 +477,7 @@ const divDefinition: FunctionDefinition = { returnType: 'unsigned_long', }, ], - supportedCommands: ['eval', 'where', 'row', 'stats', 'metrics', 'sort'], + supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'], supportedOptions: ['by'], validate: (fnDef) => { const [left, right] = fnDef.args; @@ -920,7 +947,7 @@ const equalsDefinition: FunctionDefinition = { returnType: 'boolean', }, ], - supportedCommands: ['eval', 'where', 'row', 'sort'], + supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'], supportedOptions: ['by'], validate: undefined, examples: [], @@ -1249,7 +1276,7 @@ const greaterThanDefinition: FunctionDefinition = { returnType: 'boolean', }, ], - supportedCommands: ['eval', 'where', 'row', 'sort'], + supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'], supportedOptions: ['by'], validate: undefined, examples: [], @@ -1581,7 +1608,7 @@ const greaterThanOrEqualDefinition: FunctionDefinition = { returnType: 'boolean', }, ], - supportedCommands: ['eval', 'where', 'row', 'sort'], + supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'], supportedOptions: ['by'], validate: undefined, examples: [], @@ -1823,7 +1850,7 @@ const inDefinition: FunctionDefinition = { minParams: 2, }, ], - supportedCommands: ['stats', 'inlinestats', 'metrics'], + supportedCommands: ['stats', 'inlinestats', 'metrics', '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)'], @@ -2152,7 +2179,7 @@ const lessThanDefinition: FunctionDefinition = { returnType: 'boolean', }, ], - supportedCommands: ['eval', 'where', 'row', 'sort'], + supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'], supportedOptions: ['by'], validate: undefined, examples: [], @@ -2428,7 +2455,7 @@ const lessThanOrEqualDefinition: FunctionDefinition = { returnType: 'boolean', }, ], - supportedCommands: ['eval', 'where', 'row', 'sort'], + supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'], supportedOptions: ['by'], validate: undefined, examples: [], @@ -2646,7 +2673,7 @@ const modDefinition: FunctionDefinition = { returnType: 'unsigned_long', }, ], - supportedCommands: ['eval', 'where', 'row', 'stats', 'metrics', 'sort'], + supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'], supportedOptions: ['by'], validate: (fnDef) => { const [left, right] = fnDef.args; @@ -2839,7 +2866,7 @@ const mulDefinition: FunctionDefinition = { returnType: 'unsigned_long', }, ], - supportedCommands: ['eval', 'where', 'row', 'stats', 'metrics', 'sort'], + supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'], supportedOptions: ['by'], validate: undefined, examples: [], @@ -3351,7 +3378,7 @@ const notEqualsDefinition: FunctionDefinition = { returnType: 'boolean', }, ], - supportedCommands: ['eval', 'where', 'row', 'sort'], + supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'], supportedOptions: ['by'], validate: undefined, examples: [], @@ -3630,8 +3657,34 @@ const subDefinition: FunctionDefinition = { ], 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: ['eval', 'where', 'row', 'stats', 'metrics', 'sort'], + supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'], supportedOptions: ['by'], validate: undefined, examples: [], diff --git a/packages/kbn-esql-validation-autocomplete/src/validation/esql_validation_meta_tests.json b/packages/kbn-esql-validation-autocomplete/src/validation/esql_validation_meta_tests.json index fee9f90f38c93..d069eb995cd5a 100644 --- a/packages/kbn-esql-validation-autocomplete/src/validation/esql_validation_meta_tests.json +++ b/packages/kbn-esql-validation-autocomplete/src/validation/esql_validation_meta_tests.json @@ -1060,7 +1060,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 +1125,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 +1190,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 +1255,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 +1320,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 +1385,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 +1450,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 +1515,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 +1580,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 +1645,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 +1710,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 +1775,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 +1840,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 +1905,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 +1970,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 +2035,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 +2100,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": [] }, @@ -6983,7 +6983,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": [] }, @@ -7165,7 +7165,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": [] }, @@ -7235,7 +7235,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": [] }, @@ -7305,7 +7305,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": [] }, @@ -7375,7 +7375,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": [] }, @@ -7445,7 +7445,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": [] }, @@ -7515,7 +7515,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": [] }, @@ -7585,7 +7585,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": [] }, @@ -7655,7 +7655,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": [] }, @@ -7725,7 +7725,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": [] }, @@ -7795,7 +7795,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": [] }, @@ -7865,7 +7865,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": [] }, @@ -7935,7 +7935,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": [] }, @@ -8005,7 +8005,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": [] }, @@ -8075,7 +8075,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": [] }, @@ -8145,7 +8145,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": [] }, @@ -8215,7 +8215,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": [] }, @@ -8285,7 +8285,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": [] }, @@ -8355,7 +8355,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": [] }, @@ -8425,7 +8425,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": [] }, @@ -8495,7 +8495,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": [] }, @@ -8565,7 +8565,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": [] }, @@ -8635,7 +8635,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": [] }, @@ -8705,7 +8705,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": [] }, @@ -8775,7 +8775,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": [] }, @@ -8845,7 +8845,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": [] }, @@ -8915,7 +8915,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": [] }, @@ -8985,7 +8985,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": [] }, @@ -9588,7 +9588,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": [] }, @@ -9700,275 +9700,6 @@ "warning": [ "Field [unsupportedField] cannot be retrieved, it is unsupported or not indexed; returning null" ] - }, - { - "query": "f", - "error": [ - "SyntaxError: mismatched input 'f' expecting {'explain', 'from', 'row', 'show'}" - ], - "warning": [] - }, - { - "query": "from ", - "error": [ - "SyntaxError: mismatched input '' expecting {QUOTED_STRING, UNQUOTED_SOURCE}" - ], - "warning": [] - }, - { - "query": "from index", - "error": [], - "warning": [] - }, - { - "query": "FROM index", - "error": [], - "warning": [] - }, - { - "query": "FROM \"index\"", - "error": [], - "warning": [] - }, - { - "query": "FROM \"\"\"index\"\"\"", - "error": [], - "warning": [] - }, - { - "query": "FrOm index", - "error": [], - "warning": [] - }, - { - "query": "from index, other_index", - "error": [], - "warning": [] - }, - { - "query": "from index, other_index,.secret_index", - "error": [], - "warning": [] - }, - { - "query": "from .secret_index", - "error": [], - "warning": [] - }, - { - "query": "from .secret_index", - "error": [], - "warning": [] - }, - { - "query": "from .secret_index", - "error": [], - "warning": [] - }, - { - "query": "from ind*, other*", - "error": [], - "warning": [] - }, - { - "query": "from index*", - "error": [], - "warning": [] - }, - { - "query": "FROM *a_i*dex*", - "error": [], - "warning": [] - }, - { - "query": "FROM in*ex*", - "error": [], - "warning": [] - }, - { - "query": "FROM *n*ex", - "error": [], - "warning": [] - }, - { - "query": "FROM *n*ex*", - "error": [], - "warning": [] - }, - { - "query": "FROM i*d*x*", - "error": [], - "warning": [] - }, - { - "query": "FROM i*d*x", - "error": [], - "warning": [] - }, - { - "query": "FROM i***x*", - "error": [], - "warning": [] - }, - { - "query": "FROM i****", - "error": [], - "warning": [] - }, - { - "query": "FROM i**", - "error": [], - "warning": [] - }, - { - "query": "fRoM index**", - "error": [], - "warning": [] - }, - { - "query": "fRoM *ex", - "error": [], - "warning": [] - }, - { - "query": "fRoM *ex*", - "error": [], - "warning": [] - }, - { - "query": "fRoM in*ex", - "error": [], - "warning": [] - }, - { - "query": "fRoM ind*ex", - "error": [], - "warning": [] - }, - { - "query": "fRoM *,-.*", - "error": [], - "warning": [] - }, - { - "query": "fRoM .secret_index", - "error": [], - "warning": [] - }, - { - "query": "from my-index", - "error": [], - "warning": [] - }, - { - "query": "from index,", - "error": [ - "SyntaxError: mismatched input '' expecting {QUOTED_STRING, UNQUOTED_SOURCE}" - ], - "warning": [] - }, - { - "query": "FROM index\n, \tother_index\t,\n \t ", - "error": [ - "SyntaxError: mismatched input '' expecting {QUOTED_STRING, UNQUOTED_SOURCE}" - ], - "warning": [] - }, - { - "query": "from assignment = 1", - "error": [ - "SyntaxError: mismatched input '=' expecting ", - "Unknown index [assignment]" - ], - "warning": [] - }, - { - "query": "FROM `index`", - "error": [ - "Unknown index [`index`]" - ], - "warning": [] - }, - { - "query": "from assignment = 1", - "error": [ - "SyntaxError: mismatched input '=' expecting ", - "Unknown index [assignment]" - ], - "warning": [] - }, - { - "query": "FROM index, missingIndex", - "error": [ - "Unknown index [missingIndex]" - ], - "warning": [] - }, - { - "query": "from average()", - "error": [ - "Unknown index [average()]" - ], - "warning": [] - }, - { - "query": "fRom custom_function()", - "error": [ - "Unknown index [custom_function()]" - ], - "warning": [] - }, - { - "query": "FROM indexes*", - "error": [ - "Unknown index [indexes*]" - ], - "warning": [] - }, - { - "query": "from numberField", - "error": [ - "Unknown index [numberField]" - ], - "warning": [] - }, - { - "query": "FROM policy", - "error": [ - "Unknown index [policy]" - ], - "warning": [] - }, - { - "query": "from index metadata _id", - "error": [], - "warning": [] - }, - { - "query": "from index metadata _id, \t\n _index\n ", - "error": [], - "warning": [] - }, - { - "query": "from index (metadata _id)", - "error": [ - "SyntaxError: mismatched input '(metadata' expecting " - ], - "warning": [] - }, - { - "query": "from index METADATA _id, _source2", - "error": [ - "Metadata field [_source2] is not available. Available metadata fields are: [_version, _id, _index, _source, _ignored, _index_mode]" - ], - "warning": [] - }, - { - "query": "from index metadata _id, _source METADATA _id2", - "error": [ - "SyntaxError: mismatched input 'METADATA' expecting " - ], - "warning": [] } ] } \ No newline at end of file diff --git a/packages/kbn-esql-validation-autocomplete/src/validation/validation.test.ts b/packages/kbn-esql-validation-autocomplete/src/validation/validation.test.ts index 68d8ebb233f5e..3d96c550dbb29 100644 --- a/packages/kbn-esql-validation-autocomplete/src/validation/validation.test.ts +++ b/packages/kbn-esql-validation-autocomplete/src/validation/validation.test.ts @@ -456,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}`, [ @@ -1215,7 +1215,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'", @@ -1273,7 +1273,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}`, [ @@ -1648,7 +1648,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)', From de6225eeb6ab04e584050a30d88ee0d72fc22134 Mon Sep 17 00:00:00 2001 From: Quynh Nguyen Date: Wed, 27 Nov 2024 21:38:31 -0600 Subject: [PATCH 8/8] Update tests --- .../scripts/generate_function_definitions.ts | 9 +- .../src/autocomplete/helper.ts | 8 +- .../src/definitions/generated/operators.ts | 70 ++--- .../esql_validation_meta_tests.json | 277 +++++++++++++++++- .../src/validation/helpers.ts | 2 + .../src/validation/validation.test.ts | 4 +- .../src/validation/validation.ts | 42 ++- 7 files changed, 367 insertions(+), 45 deletions(-) diff --git a/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts b/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts index fd56f5399d121..305dda331f80e 100644 --- a/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts +++ b/packages/kbn-esql-validation-autocomplete/scripts/generate_function_definitions.ts @@ -529,6 +529,12 @@ const replaceParamName = (str: string) => { 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; } @@ -545,6 +551,7 @@ const enrichOperators = ( Object.hasOwn(operatorsMeta, op.name) && operatorsMeta[op.name]?.isComparisonOperator; const isInOperator = op.name === 'in'; + const isLikeOperator = /like/i.test(op.name); const signatures = op.signatures.map((s) => ({ ...s, @@ -569,7 +576,7 @@ const enrichOperators = ( ]); supportedOptions = ['by']; } - if (isInOperator) { + if (isInOperator || isLikeOperator) { supportedCommands = _.uniq([...op.supportedCommands, 'eval', 'where', 'row', 'sort']); } if ( diff --git a/packages/kbn-esql-validation-autocomplete/src/autocomplete/helper.ts b/packages/kbn-esql-validation-autocomplete/src/autocomplete/helper.ts index 67ea324a1a69a..b455309c1f04a 100644 --- a/packages/kbn-esql-validation-autocomplete/src/autocomplete/helper.ts +++ b/packages/kbn-esql-validation-autocomplete/src/autocomplete/helper.ts @@ -112,6 +112,7 @@ export function removeQuoteForSuggestedSources(suggestions: SuggestionRawDefinit })); } +const leftHandSideParamName = new Set(['left', 'field', 'lhs']); export function getSupportedTypesForBinaryOperators( fnDef: FunctionDefinition | undefined, previousType: string @@ -119,7 +120,10 @@ export function getSupportedTypesForBinaryOperators( // Retrieve list of all 'right' supported types that match the left hand side of the function return fnDef && Array.isArray(fnDef?.signatures) ? fnDef.signatures - .filter(({ params }) => params.find((p) => p.name === 'left' && p.type === previousType)) + // @todo: add 'field' + .filter(({ params }) => + params.find((p) => leftHandSideParamName.has(p.name) && p.type === previousType) + ) .map(({ params }) => params[1].type) : [previousType]; } @@ -133,6 +137,8 @@ export function getValidFunctionSignaturesForPreviousArgs( >, argIndex: number ) { + //@TODO: remove + console.log(`--@@enrichedArgs`, enrichedArgs, 'argIndex', argIndex); // Filter down to signatures that match every params up to the current argIndex // e.g. BUCKET(longField, /) => all signatures with first param as long column type // or BUCKET(longField, 2, /) => all signatures with (longField, integer, ...) diff --git a/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts b/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts index 4eb8851879fb4..90f6498397a3a 100644 --- a/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts +++ b/packages/kbn-esql-validation-autocomplete/src/definitions/generated/operators.ts @@ -1628,12 +1628,12 @@ const inDefinition: FunctionDefinition = { { params: [ { - name: 'field', + name: 'left', type: 'boolean', optional: false, }, { - name: 'inlist', + name: 'right', type: 'boolean', optional: false, }, @@ -1644,12 +1644,12 @@ const inDefinition: FunctionDefinition = { { params: [ { - name: 'field', + name: 'left', type: 'cartesian_point', optional: false, }, { - name: 'inlist', + name: 'right', type: 'cartesian_point', optional: false, }, @@ -1660,12 +1660,12 @@ const inDefinition: FunctionDefinition = { { params: [ { - name: 'field', + name: 'left', type: 'cartesian_shape', optional: false, }, { - name: 'inlist', + name: 'right', type: 'cartesian_shape', optional: false, }, @@ -1676,12 +1676,12 @@ const inDefinition: FunctionDefinition = { { params: [ { - name: 'field', + name: 'left', type: 'double', optional: false, }, { - name: 'inlist', + name: 'right', type: 'double', optional: false, }, @@ -1692,12 +1692,12 @@ const inDefinition: FunctionDefinition = { { params: [ { - name: 'field', + name: 'left', type: 'geo_point', optional: false, }, { - name: 'inlist', + name: 'right', type: 'geo_point', optional: false, }, @@ -1708,12 +1708,12 @@ const inDefinition: FunctionDefinition = { { params: [ { - name: 'field', + name: 'left', type: 'geo_shape', optional: false, }, { - name: 'inlist', + name: 'right', type: 'geo_shape', optional: false, }, @@ -1724,12 +1724,12 @@ const inDefinition: FunctionDefinition = { { params: [ { - name: 'field', + name: 'left', type: 'integer', optional: false, }, { - name: 'inlist', + name: 'right', type: 'integer', optional: false, }, @@ -1740,12 +1740,12 @@ const inDefinition: FunctionDefinition = { { params: [ { - name: 'field', + name: 'left', type: 'ip', optional: false, }, { - name: 'inlist', + name: 'right', type: 'ip', optional: false, }, @@ -1756,12 +1756,12 @@ const inDefinition: FunctionDefinition = { { params: [ { - name: 'field', + name: 'left', type: 'keyword', optional: false, }, { - name: 'inlist', + name: 'right', type: 'keyword', optional: false, }, @@ -1772,12 +1772,12 @@ const inDefinition: FunctionDefinition = { { params: [ { - name: 'field', + name: 'left', type: 'keyword', optional: false, }, { - name: 'inlist', + name: 'right', type: 'text', optional: false, }, @@ -1788,12 +1788,12 @@ const inDefinition: FunctionDefinition = { { params: [ { - name: 'field', + name: 'left', type: 'long', optional: false, }, { - name: 'inlist', + name: 'right', type: 'long', optional: false, }, @@ -1804,12 +1804,12 @@ const inDefinition: FunctionDefinition = { { params: [ { - name: 'field', + name: 'left', type: 'text', optional: false, }, { - name: 'inlist', + name: 'right', type: 'keyword', optional: false, }, @@ -1820,12 +1820,12 @@ const inDefinition: FunctionDefinition = { { params: [ { - name: 'field', + name: 'left', type: 'text', optional: false, }, { - name: 'inlist', + name: 'right', type: 'text', optional: false, }, @@ -1836,12 +1836,12 @@ const inDefinition: FunctionDefinition = { { params: [ { - name: 'field', + name: 'left', type: 'version', optional: false, }, { - name: 'inlist', + name: 'right', type: 'version', optional: false, }, @@ -2505,7 +2505,7 @@ const likeDefinition: FunctionDefinition = { minParams: 2, }, ], - supportedCommands: ['stats', 'inlinestats', 'metrics'], + supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'], supportedOptions: undefined, validate: undefined, examples: ['FROM employees\n| WHERE first_name LIKE """?b*"""\n| KEEP first_name, last_name'], @@ -2885,7 +2885,7 @@ const negDefinition: FunctionDefinition = { { params: [ { - name: 'field', + name: 'left', type: 'date_period', optional: false, }, @@ -2895,7 +2895,7 @@ const negDefinition: FunctionDefinition = { { params: [ { - name: 'field', + name: 'left', type: 'double', optional: false, }, @@ -2905,7 +2905,7 @@ const negDefinition: FunctionDefinition = { { params: [ { - name: 'field', + name: 'left', type: 'integer', optional: false, }, @@ -2915,7 +2915,7 @@ const negDefinition: FunctionDefinition = { { params: [ { - name: 'field', + name: 'left', type: 'long', optional: false, }, @@ -2925,7 +2925,7 @@ const negDefinition: FunctionDefinition = { { params: [ { - name: 'field', + name: 'left', type: 'time_duration', optional: false, }, @@ -3428,7 +3428,7 @@ const rlikeDefinition: FunctionDefinition = { minParams: 2, }, ], - supportedCommands: ['stats', 'inlinestats', 'metrics'], + supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'], supportedOptions: undefined, validate: undefined, examples: [ diff --git a/packages/kbn-esql-validation-autocomplete/src/validation/esql_validation_meta_tests.json b/packages/kbn-esql-validation-autocomplete/src/validation/esql_validation_meta_tests.json index d069eb995cd5a..f71a21f64dd2d 100644 --- a/packages/kbn-esql-validation-autocomplete/src/validation/esql_validation_meta_tests.json +++ b/packages/kbn-esql-validation-autocomplete/src/validation/esql_validation_meta_tests.json @@ -6583,14 +6583,14 @@ { "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": [] }, { "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": [] }, @@ -6619,14 +6619,14 @@ { "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": [] }, { "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": [] }, @@ -9700,6 +9700,275 @@ "warning": [ "Field [unsupportedField] cannot be retrieved, it is unsupported or not indexed; returning null" ] + }, + { + "query": "f", + "error": [ + "SyntaxError: mismatched input 'f' expecting {'explain', 'from', 'row', 'show'}" + ], + "warning": [] + }, + { + "query": "from ", + "error": [ + "SyntaxError: mismatched input '' expecting {QUOTED_STRING, UNQUOTED_SOURCE}" + ], + "warning": [] + }, + { + "query": "from index", + "error": [], + "warning": [] + }, + { + "query": "FROM index", + "error": [], + "warning": [] + }, + { + "query": "FROM \"index\"", + "error": [], + "warning": [] + }, + { + "query": "FROM \"\"\"index\"\"\"", + "error": [], + "warning": [] + }, + { + "query": "FrOm index", + "error": [], + "warning": [] + }, + { + "query": "from index, other_index", + "error": [], + "warning": [] + }, + { + "query": "from index, other_index,.secret_index", + "error": [], + "warning": [] + }, + { + "query": "from .secret_index", + "error": [], + "warning": [] + }, + { + "query": "from .secret_index", + "error": [], + "warning": [] + }, + { + "query": "from .secret_index", + "error": [], + "warning": [] + }, + { + "query": "from ind*, other*", + "error": [], + "warning": [] + }, + { + "query": "from index*", + "error": [], + "warning": [] + }, + { + "query": "FROM *a_i*dex*", + "error": [], + "warning": [] + }, + { + "query": "FROM in*ex*", + "error": [], + "warning": [] + }, + { + "query": "FROM *n*ex", + "error": [], + "warning": [] + }, + { + "query": "FROM *n*ex*", + "error": [], + "warning": [] + }, + { + "query": "FROM i*d*x*", + "error": [], + "warning": [] + }, + { + "query": "FROM i*d*x", + "error": [], + "warning": [] + }, + { + "query": "FROM i***x*", + "error": [], + "warning": [] + }, + { + "query": "FROM i****", + "error": [], + "warning": [] + }, + { + "query": "FROM i**", + "error": [], + "warning": [] + }, + { + "query": "fRoM index**", + "error": [], + "warning": [] + }, + { + "query": "fRoM *ex", + "error": [], + "warning": [] + }, + { + "query": "fRoM *ex*", + "error": [], + "warning": [] + }, + { + "query": "fRoM in*ex", + "error": [], + "warning": [] + }, + { + "query": "fRoM ind*ex", + "error": [], + "warning": [] + }, + { + "query": "fRoM *,-.*", + "error": [], + "warning": [] + }, + { + "query": "fRoM .secret_index", + "error": [], + "warning": [] + }, + { + "query": "from my-index", + "error": [], + "warning": [] + }, + { + "query": "from index,", + "error": [ + "SyntaxError: mismatched input '' expecting {QUOTED_STRING, UNQUOTED_SOURCE}" + ], + "warning": [] + }, + { + "query": "FROM index\n, \tother_index\t,\n \t ", + "error": [ + "SyntaxError: mismatched input '' expecting {QUOTED_STRING, UNQUOTED_SOURCE}" + ], + "warning": [] + }, + { + "query": "from assignment = 1", + "error": [ + "SyntaxError: mismatched input '=' expecting ", + "Unknown index [assignment]" + ], + "warning": [] + }, + { + "query": "FROM `index`", + "error": [ + "Unknown index [`index`]" + ], + "warning": [] + }, + { + "query": "from assignment = 1", + "error": [ + "SyntaxError: mismatched input '=' expecting ", + "Unknown index [assignment]" + ], + "warning": [] + }, + { + "query": "FROM index, missingIndex", + "error": [ + "Unknown index [missingIndex]" + ], + "warning": [] + }, + { + "query": "from average()", + "error": [ + "Unknown index [average()]" + ], + "warning": [] + }, + { + "query": "fRom custom_function()", + "error": [ + "Unknown index [custom_function()]" + ], + "warning": [] + }, + { + "query": "FROM indexes*", + "error": [ + "Unknown index [indexes*]" + ], + "warning": [] + }, + { + "query": "from numberField", + "error": [ + "Unknown index [numberField]" + ], + "warning": [] + }, + { + "query": "FROM policy", + "error": [ + "Unknown index [policy]" + ], + "warning": [] + }, + { + "query": "from index metadata _id", + "error": [], + "warning": [] + }, + { + "query": "from index metadata _id, \t\n _index\n ", + "error": [], + "warning": [] + }, + { + "query": "from index (metadata _id)", + "error": [ + "SyntaxError: mismatched input '(metadata' expecting " + ], + "warning": [] + }, + { + "query": "from index METADATA _id, _source2", + "error": [ + "Metadata field [_source2] is not available. Available metadata fields are: [_version, _id, _index, _source, _ignored, _index_mode]" + ], + "warning": [] + }, + { + "query": "from index metadata _id, _source METADATA _id2", + "error": [ + "SyntaxError: mismatched input 'METADATA' expecting " + ], + "warning": [] } ] } \ No newline at end of file diff --git a/packages/kbn-esql-validation-autocomplete/src/validation/helpers.ts b/packages/kbn-esql-validation-autocomplete/src/validation/helpers.ts index 1aec1a4e512d2..a8c8241a12e34 100644 --- a/packages/kbn-esql-validation-autocomplete/src/validation/helpers.ts +++ b/packages/kbn-esql-validation-autocomplete/src/validation/helpers.ts @@ -85,6 +85,8 @@ export function collapseWrongArgumentTypeMessages( // Replace the individual "wrong argument type" messages with a single one for the whole array messages = messages.filter(({ code }) => code !== 'wrongArgumentType'); + // @TODO: remove + console.log(`--@@collapseWrongArgumentTypeMessages messages`, messages); messages.push( getMessageFromId({ messageId: 'wrongArgumentType', diff --git a/packages/kbn-esql-validation-autocomplete/src/validation/validation.test.ts b/packages/kbn-esql-validation-autocomplete/src/validation/validation.test.ts index 3d96c550dbb29..a4279af5435d1 100644 --- a/packages/kbn-esql-validation-autocomplete/src/validation/validation.test.ts +++ b/packages/kbn-esql-validation-autocomplete/src/validation/validation.test.ts @@ -1126,13 +1126,13 @@ 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( `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]`] ); // TODO: enable when https://github.com/elastic/elasticsearch/issues/108432 is complete diff --git a/packages/kbn-esql-validation-autocomplete/src/validation/validation.ts b/packages/kbn-esql-validation-autocomplete/src/validation/validation.ts index b3076d107f850..9fdb92e75d06a 100644 --- a/packages/kbn-esql-validation-autocomplete/src/validation/validation.ts +++ b/packages/kbn-esql-validation-autocomplete/src/validation/validation.ts @@ -86,6 +86,7 @@ import { UNSUPPORTED_COMMANDS_BEFORE_QSTR, } from '../shared/constants'; import { compareTypesWithLiterals } from '../shared/esql_types'; +import { getCompatibleTypesToSuggestNext, getValidFunctionSignaturesForPreviousArgs } from '../autocomplete/helper'; const NO_MESSAGE: ESQLMessage[] = []; function validateFunctionLiteralArg( @@ -613,7 +614,36 @@ 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; + + console.log("fn", fn) + //@TODO: remove + console.log(`--@@fn.args`,fn.args ); + if (fn.name === '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) => { + return ( + dataType === enrichedArgs[idx].literalType || + compareTypesWithLiterals(dataType, enrichedArgs[idx].literalType) + ); + }) + ); + //@TODO: remove + console.log(`--@@relevantFuncSignatures`,relevantFuncSignatures ); + } + + } + // Retrieve unique of types that are compatiable for the current arg + // const typesToSuggestNext = getCompatibleTypesToSuggestNext(fnDefinition, enrichedArgs, argIndex); + + for (const signature of relevantFuncSignatures) { + //@TODO: remove + // console.log(`--@@signature`,signature ); const failingSignature: ESQLMessage[] = []; fn.args.forEach((outerArg, index) => { const argDef = getParamAtPosition(signature, index); @@ -649,6 +679,7 @@ function validateFunction({ }); }); + const shouldCollapseMessages = isArrayType(argDef.type as string) && hasMultipleElements; failingSignature.push( ...(shouldCollapseMessages @@ -667,14 +698,18 @@ function validateFunction({ failingSignatures.push(failingSignature); } } + //@TODO: remove + console.log(`--@@failingSignatures`,failingSignatures ); - 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); const indexForShortestFailingsignature = failingSignatureOrderedByErrorCount[0].index; messages.push(...failingSignatures[indexForShortestFailingsignature]); } + //@TODO: remove + console.log( uniqBy(messages, ({ location }) => `${location.min}-${location.max}`)); // This is due to a special case in enrich where an implicit assignment is possible // so the AST needs to store an explicit "columnX = columnX" which duplicates the message return uniqBy(messages, ({ location }) => `${location.min}-${location.max}`); @@ -1366,6 +1401,9 @@ async function validateAst( const commandMessages = validateCommand(command, references, ast, index); messages.push(...commandMessages); } + //@TODO: remove + console.log(`--@@parsingResult.errors`, parsingResult.errors); + console.log(`--@@messages`, messages); return { errors: [...parsingResult.errors, ...messages.filter(({ type }) => type === 'error')],