Skip to content

Commit

Permalink
[8.17] [ES|QL] Update the functions definitions and tests to include …
Browse files Browse the repository at this point in the history
…date_nanos (elastic#201078) (elastic#201277)

# Backport

This will backport the following commits from `main` to `8.17`:
- [[ES|QL] Update the functions definitions and tests to include
date_nanos (elastic#201078)](elastic#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":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-21T20:05:41Z","message":"[ES|QL]
Update the functions definitions and tests to include date_nanos
(elastic#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
(elastic#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
(elastic#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 <[email protected]>
  • Loading branch information
kibanamachine and stratoula authored Nov 21, 2024
1 parent b1934ec commit d292cec
Show file tree
Hide file tree
Showing 7 changed files with 395 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'] }],
}),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ describe('autocomplete.suggest', () => {
...getFieldNamesByType([
...ESQL_COMMON_NUMERIC_TYPES,
'date',
'date_nanos',
'boolean',
'ip',
'version',
Expand All @@ -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,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>();

Expand Down Expand Up @@ -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: '(' }
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)',
Expand Down Expand Up @@ -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: [
{
Expand Down Expand Up @@ -769,6 +824,16 @@ const maxDefinition: FunctionDefinition = {
],
returnType: 'date',
},
{
params: [
{
name: 'field',
type: 'date_nanos',
optional: false,
},
],
returnType: 'date_nanos',
},
{
params: [
{
Expand Down Expand Up @@ -984,6 +1049,16 @@ const minDefinition: FunctionDefinition = {
],
returnType: 'date',
},
{
params: [
{
name: 'field',
type: 'date_nanos',
optional: false,
},
],
returnType: 'date_nanos',
},
{
params: [
{
Expand Down Expand Up @@ -1544,6 +1619,16 @@ const valuesDefinition: FunctionDefinition = {
],
returnType: 'date',
},
{
params: [
{
name: 'field',
type: 'date_nanos',
optional: false,
},
],
returnType: 'date_nanos',
},
{
params: [
{
Expand Down
Loading

0 comments on commit d292cec

Please sign in to comment.