Skip to content

Commit

Permalink
[ES|QL] min and max allow strings (#191119)
Browse files Browse the repository at this point in the history
  • Loading branch information
drewdaemon authored Aug 22, 2024
1 parent b660d42 commit 0c911c8
Show file tree
Hide file tree
Showing 4 changed files with 367 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,27 @@ describe('autocomplete.suggest', () => {
test('when typing inside function left paren', async () => {
const { assertSuggestions } = await setup();
const expected = [
...getFieldNamesByType([...ESQL_COMMON_NUMERIC_TYPES, 'date', 'boolean', 'ip']),
...getFieldNamesByType([
...ESQL_COMMON_NUMERIC_TYPES,
'date',
'boolean',
'ip',
'version',
'text',
'keyword',
]),
...getFunctionSignaturesByReturnType(
'stats',
[...ESQL_COMMON_NUMERIC_TYPES, 'date', 'date_period', 'boolean', 'ip'],
[
...ESQL_COMMON_NUMERIC_TYPES,
'date',
'date_period',
'boolean',
'ip',
'version',
'text',
'keyword',
],
{
scalar: true,
}
Expand Down
24 changes: 24 additions & 0 deletions packages/kbn-esql-validation-autocomplete/src/definitions/aggs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,18 @@ export const statsAggregationFunctionDefinitions: FunctionDefinition[] = [
params: [{ name: 'column', type: 'ip', noNestingFunctions: true }],
returnType: 'ip',
},
{
params: [{ name: 'column', type: 'version', noNestingFunctions: true }],
returnType: 'version',
},
{
params: [{ name: 'column', type: 'keyword', noNestingFunctions: true }],
returnType: 'keyword',
},
{
params: [{ name: 'column', type: 'text', noNestingFunctions: true }],
returnType: 'text',
},
],
examples: [`from index | stats result = max(field)`, `from index | stats max(field)`],
},
Expand Down Expand Up @@ -186,6 +198,18 @@ export const statsAggregationFunctionDefinitions: FunctionDefinition[] = [
params: [{ name: 'column', type: 'ip', noNestingFunctions: true }],
returnType: 'ip',
},
{
params: [{ name: 'column', type: 'version', noNestingFunctions: true }],
returnType: 'version',
},
{
params: [{ name: 'column', type: 'keyword', noNestingFunctions: true }],
returnType: 'keyword',
},
{
params: [{ name: 'column', type: 'text', noNestingFunctions: true }],
returnType: 'text',
},
],
examples: [`from index | stats result = min(field)`, `from index | stats min(field)`],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31860,23 +31860,17 @@
},
{
"query": "from a_index | stats max(concat(\"20\", \"22\"))",
"error": [
"Argument of [max] must be [double], found value [concat(\"20\",\"22\")] type [keyword]"
],
"error": [],
"warning": []
},
{
"query": "from a_index | stats var = max(textField)",
"error": [
"Argument of [max] must be [double], found value [textField] type [text]"
],
"error": [],
"warning": []
},
{
"query": "from a_index | stats max(textField)",
"error": [
"Argument of [max] must be [double], found value [textField] type [text]"
],
"error": [],
"warning": []
},
{
Expand Down Expand Up @@ -31921,6 +31915,110 @@
],
"warning": []
},
{
"query": "from a_index | stats var = max(versionField)",
"error": [],
"warning": []
},
{
"query": "from a_index | stats max(versionField)",
"error": [],
"warning": []
},
{
"query": "from a_index | stats var = max(keywordField)",
"error": [],
"warning": []
},
{
"query": "from a_index | stats max(keywordField)",
"error": [],
"warning": []
},
{
"query": "from a_index | where max(versionField)",
"error": [
"WHERE does not support function max"
],
"warning": []
},
{
"query": "from a_index | where max(versionField) > 0",
"error": [
"WHERE does not support function max"
],
"warning": []
},
{
"query": "from a_index | where max(keywordField)",
"error": [
"WHERE does not support function max"
],
"warning": []
},
{
"query": "from a_index | where max(keywordField) > 0",
"error": [
"WHERE does not support function max"
],
"warning": []
},
{
"query": "from a_index | eval var = max(versionField)",
"error": [
"EVAL does not support function max"
],
"warning": []
},
{
"query": "from a_index | eval var = max(versionField) > 0",
"error": [
"EVAL does not support function max"
],
"warning": []
},
{
"query": "from a_index | eval max(versionField)",
"error": [
"EVAL does not support function max"
],
"warning": []
},
{
"query": "from a_index | eval max(versionField) > 0",
"error": [
"EVAL does not support function max"
],
"warning": []
},
{
"query": "from a_index | eval var = max(keywordField)",
"error": [
"EVAL does not support function max"
],
"warning": []
},
{
"query": "from a_index | eval var = max(keywordField) > 0",
"error": [
"EVAL does not support function max"
],
"warning": []
},
{
"query": "from a_index | eval max(keywordField)",
"error": [
"EVAL does not support function max"
],
"warning": []
},
{
"query": "from a_index | eval max(keywordField) > 0",
"error": [
"EVAL does not support function max"
],
"warning": []
},
{
"query": "from a_index | stats var = min(doubleField)",
"error": [],
Expand Down Expand Up @@ -32500,23 +32598,17 @@
},
{
"query": "from a_index | stats min(concat(\"20\", \"22\"))",
"error": [
"Argument of [min] must be [double], found value [concat(\"20\",\"22\")] type [keyword]"
],
"error": [],
"warning": []
},
{
"query": "from a_index | stats var = min(textField)",
"error": [
"Argument of [min] must be [double], found value [textField] type [text]"
],
"error": [],
"warning": []
},
{
"query": "from a_index | stats min(textField)",
"error": [
"Argument of [min] must be [double], found value [textField] type [text]"
],
"error": [],
"warning": []
},
{
Expand Down Expand Up @@ -32561,6 +32653,110 @@
],
"warning": []
},
{
"query": "from a_index | stats var = min(versionField)",
"error": [],
"warning": []
},
{
"query": "from a_index | stats min(versionField)",
"error": [],
"warning": []
},
{
"query": "from a_index | stats var = min(keywordField)",
"error": [],
"warning": []
},
{
"query": "from a_index | stats min(keywordField)",
"error": [],
"warning": []
},
{
"query": "from a_index | where min(versionField)",
"error": [
"WHERE does not support function min"
],
"warning": []
},
{
"query": "from a_index | where min(versionField) > 0",
"error": [
"WHERE does not support function min"
],
"warning": []
},
{
"query": "from a_index | where min(keywordField)",
"error": [
"WHERE does not support function min"
],
"warning": []
},
{
"query": "from a_index | where min(keywordField) > 0",
"error": [
"WHERE does not support function min"
],
"warning": []
},
{
"query": "from a_index | eval var = min(versionField)",
"error": [
"EVAL does not support function min"
],
"warning": []
},
{
"query": "from a_index | eval var = min(versionField) > 0",
"error": [
"EVAL does not support function min"
],
"warning": []
},
{
"query": "from a_index | eval min(versionField)",
"error": [
"EVAL does not support function min"
],
"warning": []
},
{
"query": "from a_index | eval min(versionField) > 0",
"error": [
"EVAL does not support function min"
],
"warning": []
},
{
"query": "from a_index | eval var = min(keywordField)",
"error": [
"EVAL does not support function min"
],
"warning": []
},
{
"query": "from a_index | eval var = min(keywordField) > 0",
"error": [
"EVAL does not support function min"
],
"warning": []
},
{
"query": "from a_index | eval min(keywordField)",
"error": [
"EVAL does not support function min"
],
"warning": []
},
{
"query": "from a_index | eval min(keywordField) > 0",
"error": [
"EVAL does not support function min"
],
"warning": []
},
{
"query": "from a_index | stats var = count(textField)",
"error": [],
Expand Down
Loading

0 comments on commit 0c911c8

Please sign in to comment.