[ES|QL] improve test case generator script (#190441)

## Summary

Fixes a bug I introduced in
https://github.com/elastic/kibana/pull/189941

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
Drew Tate 2024-08-15 08:07:16 -06:00 committed by GitHub
parent da1db2cdeb
commit bb2cc70a3b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 234 additions and 2 deletions

View file

@ -21,8 +21,8 @@ import {
SupportedDataType,
FunctionDefinition,
dataTypes,
isSupportedDataType,
fieldTypes,
isFieldType,
} from '../src/definitions/types';
import { FUNCTION_DESCRIBE_BLOCK_NAME } from '../src/validation/function_describe_block_name';
import { getMaxMinNumberOfParams } from '../src/validation/helpers';
@ -1110,7 +1110,7 @@ function getFieldMapping(
return params.map(({ name: _name, type, constantOnly, literalOptions, ...rest }) => {
const typeString: string = type as string;
if (isSupportedDataType(typeString)) {
if (isFieldType(typeString)) {
if (useLiterals && literalOptions) {
return {
name: `"${literalOptions[0]}"`,

View file

@ -31920,6 +31920,62 @@
],
"warning": []
},
{
"query": "from a_index | stats var = max(textField)",
"error": [
"Argument of [max] must be [double], found value [textField] type [text]"
],
"warning": []
},
{
"query": "from a_index | stats max(textField)",
"error": [
"Argument of [max] must be [double], found value [textField] type [text]"
],
"warning": []
},
{
"query": "from a_index | where max(textField)",
"error": [
"WHERE does not support function max"
],
"warning": []
},
{
"query": "from a_index | where max(textField) > 0",
"error": [
"WHERE does not support function max"
],
"warning": []
},
{
"query": "from a_index | eval var = max(textField)",
"error": [
"EVAL does not support function max"
],
"warning": []
},
{
"query": "from a_index | eval var = max(textField) > 0",
"error": [
"EVAL does not support function max"
],
"warning": []
},
{
"query": "from a_index | eval max(textField)",
"error": [
"EVAL does not support function max"
],
"warning": []
},
{
"query": "from a_index | eval max(textField) > 0",
"error": [
"EVAL does not support function max"
],
"warning": []
},
{
"query": "from a_index | stats var = min(doubleField)",
"error": [],
@ -32504,6 +32560,62 @@
],
"warning": []
},
{
"query": "from a_index | stats var = min(textField)",
"error": [
"Argument of [min] must be [double], found value [textField] type [text]"
],
"warning": []
},
{
"query": "from a_index | stats min(textField)",
"error": [
"Argument of [min] must be [double], found value [textField] type [text]"
],
"warning": []
},
{
"query": "from a_index | where min(textField)",
"error": [
"WHERE does not support function min"
],
"warning": []
},
{
"query": "from a_index | where min(textField) > 0",
"error": [
"WHERE does not support function min"
],
"warning": []
},
{
"query": "from a_index | eval var = min(textField)",
"error": [
"EVAL does not support function min"
],
"warning": []
},
{
"query": "from a_index | eval var = min(textField) > 0",
"error": [
"EVAL does not support function min"
],
"warning": []
},
{
"query": "from a_index | eval min(textField)",
"error": [
"EVAL does not support function min"
],
"warning": []
},
{
"query": "from a_index | eval min(textField) > 0",
"error": [
"EVAL does not support function min"
],
"warning": []
},
{
"query": "from a_index | stats var = count(textField)",
"error": [],
@ -34937,6 +35049,42 @@
],
"warning": []
},
{
"query": "from a_index | stats by bucket(dateField, textField)",
"error": [
"Argument of [bucket] must be a constant, received [textField]"
],
"warning": []
},
{
"query": "from a_index | stats by bin(dateField, textField)",
"error": [
"Argument of [bin] must be a constant, received [textField]"
],
"warning": []
},
{
"query": "from a_index | sort bucket(dateField, textField)",
"error": [
"SORT does not support function bucket"
],
"warning": []
},
{
"query": "from a_index | stats bucket(\"2022\", textField)",
"error": [
"Argument of [bucket] must be a constant, received [textField]"
],
"warning": []
},
{
"query": "from a_index | stats bucket(concat(\"20\", \"22\"), textField)",
"error": [
"Argument of [bucket] must be [date], found value [concat(\"20\",\"22\")] type [keyword]",
"Argument of [bucket] must be a constant, received [textField]"
],
"warning": []
},
{
"query": "from a_index | stats var = percentile(doubleField, doubleField)",
"error": [

View file

@ -12284,6 +12284,38 @@ describe('validation logic', () => {
testErrorsAndWarnings('from a_index | stats max(concat("20", "22"))', [
'Argument of [max] must be [double], found value [concat("20","22")] type [keyword]',
]);
testErrorsAndWarnings('from a_index | stats var = max(textField)', [
'Argument of [max] must be [double], found value [textField] type [text]',
]);
testErrorsAndWarnings('from a_index | stats max(textField)', [
'Argument of [max] must be [double], found value [textField] type [text]',
]);
testErrorsAndWarnings('from a_index | where max(textField)', [
'WHERE does not support function max',
]);
testErrorsAndWarnings('from a_index | where max(textField) > 0', [
'WHERE does not support function max',
]);
testErrorsAndWarnings('from a_index | eval var = max(textField)', [
'EVAL does not support function max',
]);
testErrorsAndWarnings('from a_index | eval var = max(textField) > 0', [
'EVAL does not support function max',
]);
testErrorsAndWarnings('from a_index | eval max(textField)', [
'EVAL does not support function max',
]);
testErrorsAndWarnings('from a_index | eval max(textField) > 0', [
'EVAL does not support function max',
]);
});
describe('min', () => {
@ -12606,6 +12638,38 @@ describe('validation logic', () => {
testErrorsAndWarnings('from a_index | stats min(concat("20", "22"))', [
'Argument of [min] must be [double], found value [concat("20","22")] type [keyword]',
]);
testErrorsAndWarnings('from a_index | stats var = min(textField)', [
'Argument of [min] must be [double], found value [textField] type [text]',
]);
testErrorsAndWarnings('from a_index | stats min(textField)', [
'Argument of [min] must be [double], found value [textField] type [text]',
]);
testErrorsAndWarnings('from a_index | where min(textField)', [
'WHERE does not support function min',
]);
testErrorsAndWarnings('from a_index | where min(textField) > 0', [
'WHERE does not support function min',
]);
testErrorsAndWarnings('from a_index | eval var = min(textField)', [
'EVAL does not support function min',
]);
testErrorsAndWarnings('from a_index | eval var = min(textField) > 0', [
'EVAL does not support function min',
]);
testErrorsAndWarnings('from a_index | eval min(textField)', [
'EVAL does not support function min',
]);
testErrorsAndWarnings('from a_index | eval min(textField) > 0', [
'EVAL does not support function min',
]);
});
describe('count', () => {
@ -14564,6 +14628,26 @@ describe('validation logic', () => {
'Argument of [bin] must be a constant, received [longField]',
]
);
testErrorsAndWarnings('from a_index | stats by bucket(dateField, textField)', [
'Argument of [bucket] must be a constant, received [textField]',
]);
testErrorsAndWarnings('from a_index | stats by bin(dateField, textField)', [
'Argument of [bin] must be a constant, received [textField]',
]);
testErrorsAndWarnings('from a_index | sort bucket(dateField, textField)', [
'SORT does not support function bucket',
]);
testErrorsAndWarnings('from a_index | stats bucket("2022", textField)', [
'Argument of [bucket] must be a constant, received [textField]',
]);
testErrorsAndWarnings('from a_index | stats bucket(concat("20", "22"), textField)', [
'Argument of [bucket] must be [date], found value [concat("20","22")] type [keyword]',
'Argument of [bucket] must be a constant, received [textField]',
]);
});
describe('percentile', () => {