Skip to content

EQL: Allow sample queries without a timestamp field#90629

Merged
luigidellaquila merged 3 commits intoelastic:feature/eql_samplesfrom
luigidellaquila:eql/no_timestamp_on_samples
Oct 5, 2022
Merged

EQL: Allow sample queries without a timestamp field#90629
luigidellaquila merged 3 commits intoelastic:feature/eql_samplesfrom
luigidellaquila:eql/no_timestamp_on_samples

Conversation

@luigidellaquila
Copy link
Copy Markdown
Contributor

@luigidellaquila luigidellaquila commented Oct 4, 2022

Sample queries do not rely on time sequences, so they don't need a timestamp field to execute.
Since Samples were implemented within current EQL framework, they inherited all the checks for the presence of a timestamp field in the target index(es), even though it was not actually used.
This PR removes this limitation.

@luigidellaquila luigidellaquila marked this pull request as ready for review October 4, 2022 09:06
@elasticsearchmachine elasticsearchmachine added the Team:QL (Deprecated) Meta label for query languages team label Oct 4, 2022
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-ql (Team:QL)

);
Filter joinKeyNotNull = new Filter(join.source(), k.child(), constraint);
filters.set(i, new KeyedFilter(k.source(), joinKeyNotNull, k.keys(), k.timestamp(), k.timestamp()));
filters.set(i, new KeyedFilter(k.source(), joinKeyNotNull, k.keys(), k.timestamp(), k.tiebreaker()));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like an oversight in the original implementation, not specifically related to this fix (I just took the chance to fix it)

Copy link
Copy Markdown
Contributor

@astefan astefan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the solution but not with the tests. Also, the solution is fixing the timestamp_field part, but extrapolating this a bit, it doesn't cover the tiebreaker field as well.

At the moment, a very similar test, but specifying a "tiebreaker_field" results in the same error as the one for the timestamp_field.

Removing the date fields from the sample*.data files is not actually testing the fix. To make it more diverse, instead, you could keep sample1 and sample2 as is and remove the timestamp fields from sample3. Still, this doesn't test the fix, but it makes the IT tests more complex.

To test the fix you could probably test the verifier outcome for timestamp_field and tiebreaker_field presence.

List<NamedExpression> out = new ArrayList<>();

out.add(timestamp);
if (Expressions.isPresent(timestamp)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment here for the scenario when the timestamp is not actually present, even though is a required request parameter.
Also, adjust the class level comment of this class which says "Used inside Join or Sequence".

and add one more test
@luigidellaquila
Copy link
Copy Markdown
Contributor Author

Thanks for the comments @astefan, adding a few notes below:

At the moment, a very similar test, but specifying a "tiebreaker_field" results in the same error as the one for the timestamp_field.

Not sure if this case should be considered a user mistake (explicitly specify a tiebreaker field that does not exist), but the fix is easy, so I added it as well.

Removing the date fields from the sample*.data files is not actually testing the fix. To make it more diverse, instead, you could keep sample1 and sample2 as is and remove the timestamp fields from sample3. Still, this doesn't test the fix, but it makes the IT tests more complex.

It's the opposite actually: if at least one index has the @timestamp field, the query succeeds. The only way to make it fail is to remove it from all the indexes in the pattern.
I agree with you on the usefulness of a unit test for the verifier, I just added it

Copy link
Copy Markdown
Contributor

@astefan astefan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

@bpintea bpintea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm.

@luigidellaquila
Copy link
Copy Markdown
Contributor Author

@elasticmachine run elasticsearch-ci/rest-compatibility

@luigidellaquila luigidellaquila merged commit 044fa99 into elastic:feature/eql_samples Oct 5, 2022
@luigidellaquila luigidellaquila mentioned this pull request Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/EQL EQL querying >bug Team:QL (Deprecated) Meta label for query languages team v8.6.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants