-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Add last_over_time #126650
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
Add last_over_time #126650
Conversation
I opened this PR for discussion. Perhaps we should implement |
...compute/src/main/java/org/elasticsearch/compute/aggregation/X-LastOverTimeAggregator.java.st
Outdated
Show resolved
Hide resolved
long timestamp = timestamps.getLong(timestamps.getFirstValueIndex(otherPosition)); | ||
int firstIndex = values.getFirstValueIndex(otherPosition); | ||
for (int i = 0; i < valueCount; i++) { | ||
current.maybeCollect(groupId, timestamp, values.get$Type$(firstIndex + i)); |
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.
Lemme see if I understand this. Should this be returning a boolean to indicate if we found the last value? Assuming we're scanning in reverse chrono order, the first match should stop iteration over the values in the bucket.
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.
We don't have a mechanism to signal this. I renamed maybeCollect to collectValue to make it less confusing.
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.
Let's add a comment about this, seems like an important optimization - e.g. for aggs with TBUCKET(1 day)
, we may scan 1 value vs 1m values, iiuc?
Right, I wonder if the following query makes sense:
which should be equivalent to
I can't think of other uses of |
@kkrik-es Thank you for the feedback. I was considering implementing last_over_time to be equivalent to the last_over_time function in PromQL. I am not sure about the output of your proposal ![]() |
Right the last would calculate the last value of the per-tsid last values, e.g. per host. I don't see it in the listed functions, not sure if it's supported in PromQL.. @felixbarny too. |
Hey Nhat, is this blocked? Shall we just move fwd with what you have, maybe adding comments to revisit the logic and terminate early, if possible? |
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
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.
LGTM 👍
@kkrik-es @martijnvg Thanks for reviews. |
This PR introduces a time-series aggregation function that collects the last value of each time series within each grouping.
For example:
This aggregate function should support all data types, but currently, it only supports
int
,long
,float
, anddouble
. Support for additional data types will be added later. Another issue is the lack of unit test infra for time-series and time-series aggregators. I plan to address them soon.