-
Notifications
You must be signed in to change notification settings - Fork 25.5k
More validation for time-series aggregations #134413
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
Conversation
984cc32
to
5dcb2bf
Compare
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
failures.add( | ||
fail( | ||
ts, | ||
"over-time aggregate function [{}] can only be used with the TS command and inside another aggregate function", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@not-napoleon fyi
for (Expression g : groupings) { | ||
boolean timeBucket = g.anyMatch( | ||
c -> (c instanceof Bucket b && b.field().equals(timestamp.get()) | ||
|| (c instanceof TBucket tb && tb.field().equals(timestamp.get()))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check for date_trunk too?
nested -> failures.add( | ||
fail( | ||
this, | ||
"cannot use aggregate function [{}] inside over-time aggregation function [{}]", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: maybe replace over-time
with time-series
, here and below?
1:22: nested aggregations [avg(rate(network.bytes_in))] \ | ||
not allowed inside other aggregations [max(avg(rate(network.bytes_in)))] | ||
line 1:12: cannot use aggregate function [avg(rate(network.bytes_in))] \ | ||
inside over-time aggregation function [rate(network.bytes_in)]""")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This second error is somewhat confusing - avg
is not used inside rate
. Overtriggering?
1:23: limiting [LIMIT 10] the time-series source \ | ||
before the first aggregation [STATS avg(network.connections)] is not allowed; filter data with a WHERE command instead | ||
line 1:11: sorting [SORT host] between the time-series source \ | ||
and the first aggregation [STATS avg(network.connections)] is not allowed""")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a couple of examples with SORT and LIMIT after STATS to verify that the error doesn't overtrigger.
assertThat( | ||
error("TS test | INLINESTATS v = avg(network.connections) | STATS max(v)", tsdb), | ||
equalTo("1:11: InlineStats [INLINESTATS v = avg(network.connections)] in time-series is only allowed after an aggregation") | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a simple example with INLINESTATS after STATS - if that makes sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was quick, thanks Nhat!
BASE=3c3058e6f63c5ebdcc4513fc5dcc4ffb3ec8a752 HEAD=69b95e47c4d65a8c6903b6f532b08d03d5406360 Branch=main
BASE=3c3058e6f63c5ebdcc4513fc5dcc4ffb3ec8a752 HEAD=69b95e47c4d65a8c6903b6f532b08d03d5406360 Branch=main
BASE=3c3058e6f63c5ebdcc4513fc5dcc4ffb3ec8a752 HEAD=69b95e47c4d65a8c6903b6f532b08d03d5406360 Branch=main
Add validations to reject the following queries until supported:
Limit and sort cannot be used to alter the time-series source:
TS metrics | LIMIT ... | STATS ...
TS metrics | SORT BY ... | STATS ...
Over-time aggregation without an outer aggregation (to be supported soon):
TS metrics | STATS rate(requests)
TS metrics | STATS last_over_time(requests)
Reject lookup join, enrich, change point before the first stats.
Closes #134366
Closes #134372