mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
# Backport This will backport the following commits from `main` to `8.17`: - [[ES|QL] Update the functions definitions and tests to include date_nanos (#201078)](https://github.com/elastic/kibana/pull/201078) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Stratoula Kalafateli","email":"efstratia.kalafateli@elastic.co"},"sourceCommit":{"committedDate":"2024-11-21T20:05:41Z","message":"[ES|QL] Update the functions definitions and tests to include date_nanos (#201078)","sha":"9da8f87a8690e083c1c763941bd4e36d997f3de2","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Feature:ES|QL","Team:ESQL","backport:version","v8.17.0","v8.18.0"],"title":"[ES|QL] Update the functions definitions and tests to include date_nanos","number":201078,"url":"https://github.com/elastic/kibana/pull/201078","mergeCommit":{"message":"[ES|QL] Update the functions definitions and tests to include date_nanos (#201078)","sha":"9da8f87a8690e083c1c763941bd4e36d997f3de2"}},"sourceBranch":"main","suggestedTargetBranches":["8.17","8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201078","number":201078,"mergeCommit":{"message":"[ES|QL] Update the functions definitions and tests to include date_nanos (#201078)","sha":"9da8f87a8690e083c1c763941bd4e36d997f3de2"}},{"branch":"8.17","label":"v8.17.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
This commit is contained in:
parent
b1934ec8ba
commit
d292cece34
7 changed files with 395 additions and 22 deletions
|
@ -218,7 +218,7 @@ const functionEnrichments: Record<string, RecursivePartial<FunctionDefinition>>
|
|||
],
|
||||
},
|
||||
mv_sort: {
|
||||
signatures: new Array(9).fill({
|
||||
signatures: new Array(10).fill({
|
||||
params: [{}, { acceptedValues: ['asc', 'desc'] }],
|
||||
}),
|
||||
},
|
||||
|
|
|
@ -150,6 +150,7 @@ describe('autocomplete.suggest', () => {
|
|||
...getFieldNamesByType([
|
||||
...ESQL_COMMON_NUMERIC_TYPES,
|
||||
'date',
|
||||
'date_nanos',
|
||||
'boolean',
|
||||
'ip',
|
||||
'version',
|
||||
|
@ -158,7 +159,16 @@ describe('autocomplete.suggest', () => {
|
|||
]),
|
||||
...getFunctionSignaturesByReturnType(
|
||||
'stats',
|
||||
[...ESQL_COMMON_NUMERIC_TYPES, 'date', 'boolean', 'ip', 'version', 'text', 'keyword'],
|
||||
[
|
||||
...ESQL_COMMON_NUMERIC_TYPES,
|
||||
'date',
|
||||
'boolean',
|
||||
'ip',
|
||||
'version',
|
||||
'text',
|
||||
'keyword',
|
||||
'date_nanos',
|
||||
],
|
||||
{
|
||||
scalar: true,
|
||||
}
|
||||
|
|
|
@ -370,8 +370,12 @@ describe('autocomplete.suggest', () => {
|
|||
// // Test suggestions for each possible param, within each signature variation, for each function
|
||||
for (const fn of scalarFunctionDefinitions) {
|
||||
// skip this fn for the moment as it's quite hard to test
|
||||
// Add match in the text when the autocomplete is ready https://github.com/elastic/kibana/issues/196995
|
||||
if (!['bucket', 'date_extract', 'date_diff', 'case', 'match', 'qstr'].includes(fn.name)) {
|
||||
// Add match in the test when the autocomplete is ready https://github.com/elastic/kibana/issues/196995
|
||||
if (
|
||||
!['bucket', 'date_extract', 'date_diff', 'case', 'match', 'qstr', 'date_trunc'].includes(
|
||||
fn.name
|
||||
)
|
||||
) {
|
||||
test(`${fn.name}`, async () => {
|
||||
const testedCases = new Set<string>();
|
||||
|
||||
|
@ -539,9 +543,9 @@ describe('autocomplete.suggest', () => {
|
|||
'from a | eval var0=date_trunc(/)',
|
||||
[
|
||||
...getLiteralsByType('time_literal').map((t) => `${t}, `),
|
||||
...getFunctionSignaturesByReturnType('eval', 'time_duration', { scalar: true }).map(
|
||||
(t) => `${t.text},`
|
||||
),
|
||||
...getFunctionSignaturesByReturnType('eval', ['time_duration', 'date_period'], {
|
||||
scalar: true,
|
||||
}).map((t) => `${t.text},`),
|
||||
],
|
||||
{ triggerCharacter: '(' }
|
||||
);
|
||||
|
|
|
@ -216,7 +216,7 @@ const countDefinition: FunctionDefinition = {
|
|||
validate: undefined,
|
||||
examples: [
|
||||
'FROM employees\n| STATS COUNT(height)',
|
||||
'FROM employees \n| STATS count = COUNT(*) BY languages \n| SORT languages DESC',
|
||||
'FROM employees\n| STATS count = COUNT(*) BY languages\n| SORT languages DESC',
|
||||
'ROW words="foo;bar;baz;qux;quux;foo"\n| STATS word_count = COUNT(SPLIT(words, ";"))',
|
||||
'ROW n=1\n| WHERE n < 0\n| STATS COUNT(n)',
|
||||
'ROW n=1\n| STATS COUNT(n > 0 OR NULL), COUNT(n < 0 OR NULL)',
|
||||
|
@ -343,6 +343,61 @@ const countDistinctDefinition: FunctionDefinition = {
|
|||
],
|
||||
returnType: 'long',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'field',
|
||||
type: 'date_nanos',
|
||||
optional: false,
|
||||
},
|
||||
],
|
||||
returnType: 'long',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'field',
|
||||
type: 'date_nanos',
|
||||
optional: false,
|
||||
},
|
||||
{
|
||||
name: 'precision',
|
||||
type: 'integer',
|
||||
optional: true,
|
||||
},
|
||||
],
|
||||
returnType: 'long',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'field',
|
||||
type: 'date_nanos',
|
||||
optional: false,
|
||||
},
|
||||
{
|
||||
name: 'precision',
|
||||
type: 'long',
|
||||
optional: true,
|
||||
},
|
||||
],
|
||||
returnType: 'long',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'field',
|
||||
type: 'date_nanos',
|
||||
optional: false,
|
||||
},
|
||||
{
|
||||
name: 'precision',
|
||||
type: 'unsigned_long',
|
||||
optional: true,
|
||||
},
|
||||
],
|
||||
returnType: 'long',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
|
@ -769,6 +824,16 @@ const maxDefinition: FunctionDefinition = {
|
|||
],
|
||||
returnType: 'date',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'field',
|
||||
type: 'date_nanos',
|
||||
optional: false,
|
||||
},
|
||||
],
|
||||
returnType: 'date_nanos',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
|
@ -984,6 +1049,16 @@ const minDefinition: FunctionDefinition = {
|
|||
],
|
||||
returnType: 'date',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'field',
|
||||
type: 'date_nanos',
|
||||
optional: false,
|
||||
},
|
||||
],
|
||||
returnType: 'date_nanos',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
|
@ -1544,6 +1619,16 @@ const valuesDefinition: FunctionDefinition = {
|
|||
],
|
||||
returnType: 'date',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'field',
|
||||
type: 'date_nanos',
|
||||
optional: false,
|
||||
},
|
||||
],
|
||||
returnType: 'date_nanos',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
|
|
|
@ -814,6 +814,22 @@ const coalesceDefinition: FunctionDefinition = {
|
|||
returnType: 'date',
|
||||
minParams: 1,
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'first',
|
||||
type: 'date_nanos',
|
||||
optional: false,
|
||||
},
|
||||
{
|
||||
name: 'rest',
|
||||
type: 'date_nanos',
|
||||
optional: true,
|
||||
},
|
||||
],
|
||||
returnType: 'date_nanos',
|
||||
minParams: 1,
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
|
@ -1546,6 +1562,21 @@ const dateTruncDefinition: FunctionDefinition = {
|
|||
],
|
||||
returnType: 'date',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'interval',
|
||||
type: 'date_period',
|
||||
optional: false,
|
||||
},
|
||||
{
|
||||
name: 'date',
|
||||
type: 'date_nanos',
|
||||
optional: false,
|
||||
},
|
||||
],
|
||||
returnType: 'date_nanos',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
|
@ -1561,6 +1592,21 @@ const dateTruncDefinition: FunctionDefinition = {
|
|||
],
|
||||
returnType: 'date',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'interval',
|
||||
type: 'time_duration',
|
||||
optional: false,
|
||||
},
|
||||
{
|
||||
name: 'date',
|
||||
type: 'date_nanos',
|
||||
optional: false,
|
||||
},
|
||||
],
|
||||
returnType: 'date_nanos',
|
||||
},
|
||||
],
|
||||
supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'],
|
||||
supportedOptions: ['by'],
|
||||
|
@ -1876,6 +1922,22 @@ const greatestDefinition: FunctionDefinition = {
|
|||
returnType: 'date',
|
||||
minParams: 1,
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'first',
|
||||
type: 'date_nanos',
|
||||
optional: false,
|
||||
},
|
||||
{
|
||||
name: 'rest',
|
||||
type: 'date_nanos',
|
||||
optional: true,
|
||||
},
|
||||
],
|
||||
returnType: 'date_nanos',
|
||||
minParams: 1,
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
|
@ -2390,6 +2452,22 @@ const leastDefinition: FunctionDefinition = {
|
|||
returnType: 'date',
|
||||
minParams: 1,
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'first',
|
||||
type: 'date_nanos',
|
||||
optional: false,
|
||||
},
|
||||
{
|
||||
name: 'rest',
|
||||
type: 'date_nanos',
|
||||
optional: true,
|
||||
},
|
||||
],
|
||||
returnType: 'date_nanos',
|
||||
minParams: 1,
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
|
@ -3322,7 +3400,7 @@ const matchDefinition: FunctionDefinition = {
|
|||
supportedOptions: [],
|
||||
validate: undefined,
|
||||
examples: [
|
||||
'from books \n| where match(author, "Faulkner")\n| keep book_no, author \n| sort book_no \n| limit 5;',
|
||||
'FROM books \n| WHERE MATCH(author, "Faulkner")\n| KEEP book_no, author \n| SORT book_no \n| LIMIT 5;',
|
||||
],
|
||||
};
|
||||
|
||||
|
@ -3728,6 +3806,16 @@ const mvCountDefinition: FunctionDefinition = {
|
|||
],
|
||||
returnType: 'integer',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'field',
|
||||
type: 'date_nanos',
|
||||
optional: false,
|
||||
},
|
||||
],
|
||||
returnType: 'integer',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
|
@ -3885,6 +3973,16 @@ const mvDedupeDefinition: FunctionDefinition = {
|
|||
],
|
||||
returnType: 'date',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'field',
|
||||
type: 'date_nanos',
|
||||
optional: false,
|
||||
},
|
||||
],
|
||||
returnType: 'date_nanos',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
|
@ -4033,6 +4131,16 @@ const mvFirstDefinition: FunctionDefinition = {
|
|||
],
|
||||
returnType: 'date',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'field',
|
||||
type: 'date_nanos',
|
||||
optional: false,
|
||||
},
|
||||
],
|
||||
returnType: 'date_nanos',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
|
@ -4191,6 +4299,16 @@ const mvLastDefinition: FunctionDefinition = {
|
|||
],
|
||||
returnType: 'date',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'field',
|
||||
type: 'date_nanos',
|
||||
optional: false,
|
||||
},
|
||||
],
|
||||
returnType: 'date_nanos',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
|
@ -4329,6 +4447,16 @@ const mvMaxDefinition: FunctionDefinition = {
|
|||
],
|
||||
returnType: 'date',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'field',
|
||||
type: 'date_nanos',
|
||||
optional: false,
|
||||
},
|
||||
],
|
||||
returnType: 'date_nanos',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
|
@ -4574,6 +4702,16 @@ const mvMinDefinition: FunctionDefinition = {
|
|||
],
|
||||
returnType: 'date',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'field',
|
||||
type: 'date_nanos',
|
||||
optional: false,
|
||||
},
|
||||
],
|
||||
returnType: 'date_nanos',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
|
@ -4948,6 +5086,26 @@ const mvSliceDefinition: FunctionDefinition = {
|
|||
],
|
||||
returnType: 'date',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'field',
|
||||
type: 'date_nanos',
|
||||
optional: false,
|
||||
},
|
||||
{
|
||||
name: 'start',
|
||||
type: 'integer',
|
||||
optional: false,
|
||||
},
|
||||
{
|
||||
name: 'end',
|
||||
type: 'integer',
|
||||
optional: true,
|
||||
},
|
||||
],
|
||||
returnType: 'date_nanos',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
|
@ -5180,6 +5338,22 @@ const mvSortDefinition: FunctionDefinition = {
|
|||
],
|
||||
returnType: 'date',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'field',
|
||||
type: 'date_nanos',
|
||||
optional: false,
|
||||
},
|
||||
{
|
||||
name: 'order',
|
||||
type: 'keyword',
|
||||
optional: true,
|
||||
acceptedValues: ['asc', 'desc'],
|
||||
},
|
||||
],
|
||||
returnType: 'date_nanos',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
|
@ -5937,7 +6111,7 @@ const qstrDefinition: FunctionDefinition = {
|
|||
supportedOptions: [],
|
||||
validate: undefined,
|
||||
examples: [
|
||||
'from books \n| where qstr("author: Faulkner")\n| keep book_no, author \n| sort book_no \n| limit 5;',
|
||||
'FROM books \n| WHERE QSTR("author: Faulkner")\n| KEEP book_no, author \n| SORT book_no \n| LIMIT 5;',
|
||||
],
|
||||
};
|
||||
|
||||
|
@ -7950,7 +8124,78 @@ const toDateNanosDefinition: FunctionDefinition = {
|
|||
}),
|
||||
preview: true,
|
||||
alias: undefined,
|
||||
signatures: [],
|
||||
signatures: [
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'field',
|
||||
type: 'date',
|
||||
optional: false,
|
||||
},
|
||||
],
|
||||
returnType: 'date_nanos',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'field',
|
||||
type: 'date_nanos',
|
||||
optional: false,
|
||||
},
|
||||
],
|
||||
returnType: 'date_nanos',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'field',
|
||||
type: 'double',
|
||||
optional: false,
|
||||
},
|
||||
],
|
||||
returnType: 'date_nanos',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'field',
|
||||
type: 'keyword',
|
||||
optional: false,
|
||||
},
|
||||
],
|
||||
returnType: 'date_nanos',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'field',
|
||||
type: 'long',
|
||||
optional: false,
|
||||
},
|
||||
],
|
||||
returnType: 'date_nanos',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'field',
|
||||
type: 'text',
|
||||
optional: false,
|
||||
},
|
||||
],
|
||||
returnType: 'date_nanos',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'field',
|
||||
type: 'unsigned_long',
|
||||
optional: false,
|
||||
},
|
||||
],
|
||||
returnType: 'date_nanos',
|
||||
},
|
||||
],
|
||||
supportedCommands: ['stats', 'inlinestats', 'metrics', 'eval', 'where', 'row', 'sort'],
|
||||
supportedOptions: ['by'],
|
||||
validate: undefined,
|
||||
|
@ -8027,6 +8272,16 @@ const toDatetimeDefinition: FunctionDefinition = {
|
|||
],
|
||||
returnType: 'date',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'field',
|
||||
type: 'date_nanos',
|
||||
optional: false,
|
||||
},
|
||||
],
|
||||
returnType: 'date',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
|
@ -8600,6 +8855,16 @@ const toLongDefinition: FunctionDefinition = {
|
|||
],
|
||||
returnType: 'long',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'field',
|
||||
type: 'date_nanos',
|
||||
optional: false,
|
||||
},
|
||||
],
|
||||
returnType: 'long',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
|
@ -8813,6 +9078,16 @@ const toStringDefinition: FunctionDefinition = {
|
|||
],
|
||||
returnType: 'keyword',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
name: 'field',
|
||||
type: 'date_nanos',
|
||||
optional: false,
|
||||
},
|
||||
],
|
||||
returnType: 'keyword',
|
||||
},
|
||||
{
|
||||
params: [
|
||||
{
|
||||
|
|
|
@ -429,7 +429,6 @@ describe('validation logic', () => {
|
|||
[],
|
||||
['Invalid option ["bogus"] for mv_sort. Supported options: ["asc", "desc"].']
|
||||
);
|
||||
|
||||
testErrorsAndWarnings(`row var = mv_sort(["a", "b"], "ASC")`, []);
|
||||
testErrorsAndWarnings(`row var = mv_sort(["a", "b"], "DESC")`, []);
|
||||
|
||||
|
|
|
@ -1204,11 +1204,11 @@ export const functions = {
|
|||
Performs a match query on the specified field. Returns true if the provided query matches the row.
|
||||
|
||||
\`\`\`
|
||||
from books
|
||||
| where match(author, "Faulkner")
|
||||
| keep book_no, author
|
||||
| sort book_no
|
||||
| limit 5;
|
||||
FROM books
|
||||
| WHERE MATCH(author, "Faulkner")
|
||||
| KEEP book_no, author
|
||||
| SORT book_no
|
||||
| LIMIT 5;
|
||||
\`\`\`
|
||||
`,
|
||||
description:
|
||||
|
@ -1920,11 +1920,11 @@ export const functions = {
|
|||
Performs a query string query. Returns true if the provided query string matches the row.
|
||||
|
||||
\`\`\`
|
||||
from books
|
||||
| where qstr("author: Faulkner")
|
||||
| keep book_no, author
|
||||
| sort book_no
|
||||
| limit 5;
|
||||
FROM books
|
||||
| WHERE QSTR("author: Faulkner")
|
||||
| KEEP book_no, author
|
||||
| SORT book_no
|
||||
| LIMIT 5;
|
||||
\`\`\`
|
||||
`,
|
||||
description:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue