Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ES|QL] Update the functions definitions and tests to include date_nanos #201078

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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