You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE] PPL earliest/latest aggregation function support #3639
Is your feature request related to a problem?
We need to support earliest/latest as aggregate function, it calcite the earliest/latest time for a time related column. Also, it should be supported in eventstat as well
@LantaoJin@xinyual I'm doing gap analysis for this and have questions below. As I understand, PR #3640 adds earliest and latest function as scalar conditional function.
This issue is not resolved right? Shall we reopen it?
Could you share the SPL doc that earliest and latest as conditional function?
Prerequisite: We need to define implicit internal field _time first, similarly as _raw field.
For similar cases like timechart, we use @timestamp#3965 (comment) Can we reuse similar implementation here?
Do you have time to finish this? If not, I can take this.
@xinyual Thanks for the context. I wasn't aware of that.
We reviewed this today and decide to add an optional argument to let users specify a time field other than @timestamp (e.g., source=accounts | stats earliest(age, time)). cc: @ykmr1224
We reviewed this today and decide to add an optional argument to let users specify a time field other than @timestamp (e.g., source=accounts | stats earliest(age, time)). cc: @ykmr1224
Is this the decision for all time modifier cases, e.g. timechart? We will set a default field @timestamp and also allow user to input time field. If so, we should also change the implementation of conditional function earliest/latest. Currently it asks customer to input a time field.
We reviewed this today and decide to add an optional argument to let users specify a time field other than @timestamp (e.g., source=accounts | stats earliest(age, time)). cc: @ykmr1224
Is this the decision for all time modifier cases, e.g. timechart? We will set a default field @timestamp and also allow user to input time field. If so, we should also change the implementation of conditional function earliest/latest. Currently it asks customer to input a time field.
@ykmr1224 Could you follow up with this? As I understand, the current approach is: for any function implicitly relies on _time field, users can do the same without specifying @timestamp. Meanwhile we provide optional argument additionally in case the time field name is different.
We also discussed a bit about _raw field support which we want to provide a setting. Probably that's also an option for any internal/default fields like _time? cc: @penghuo
Activity
dai-chen commentedon Aug 13, 2025
@LantaoJin @xinyual I'm doing gap analysis for this and have questions below. As I understand, PR #3640 adds
earliestandlatestfunction as scalar conditional function.earliestandlatestas conditional function?3 remaining items
dai-chen commentedon Aug 15, 2025
Implementation Options
statscommandearliest(field)/latest(field)=>min_by(field, _time)/max_by(field, _time)_timefieldeventstatscommandFIRST_VALUE(x) OVER (PARTITION BY ... ORDER BY _time ASC ...)Prerequisite: We need to define implicit internal field
_timefirst, similarly as_rawfield.xinyual commentedon Aug 18, 2025
For similar cases like timechart, we use
@timestamp#3965 (comment) Can we reuse similar implementation here?Do you have time to finish this? If not, I can take this.
dai-chen commentedon Aug 18, 2025
@xinyual Thanks for the context. I wasn't aware of that.
We reviewed this today and decide to add an optional argument to let users specify a time field other than
@timestamp(e.g.,source=accounts | stats earliest(age, time)). cc: @ykmr1224xinyual commentedon Aug 19, 2025
Is this the decision for all time modifier cases, e.g. timechart? We will set a default field
@timestampand also allow user to input time field. If so, we should also change the implementation of conditional functionearliest/latest. Currently it asks customer to input a time field.dai-chen commentedon Aug 19, 2025
@ykmr1224 Could you follow up with this? As I understand, the current approach is: for any function implicitly relies on
_timefield, users can do the same without specifying@timestamp. Meanwhile we provide optional argument additionally in case the time field name is different.We also discussed a bit about
_rawfield support which we want to provide a setting. Probably that's also an option for any internal/default fields like_time? cc: @penghuoykmr1224 commentedon Aug 29, 2025
I will work on another PR for earliest/latest with eventstats(#4047).
ykmr1224 commentedon Sep 16, 2025
earliest/latest is now supported in eventstats: #4212