Skip to content

Commit

Permalink
[ES|QL] Update the functions definitions and tests to include date_na…
Browse files Browse the repository at this point in the history
  • Loading branch information
stratoula authored and paulinashakirova committed Nov 26, 2024
1 parent a2a2a64 commit b96d6be
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 b96d6be

Please sign in to comment.