-
Notifications
You must be signed in to change notification settings - Fork 33
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
[FEATURE] Support Relative Date-time Strings #991
Comments
@YANG-DB Is this an acceptable limitation for the initial implementation? I think this covers the majority of use cases, and would allow us to get earliest/latest implemented a bit quicker. Once that's done, we can come back to add this functionality if it's needed. |
Agree - thanks @currantw |
* Unrelated typos Signed-off-by: currantw <taylor.curran@improving.com> * Initial implementation of relative date time logic and unit tests Signed-off-by: currantw <taylor.curran@improving.com> * Minor cleanup Signed-off-by: currantw <taylor.curran@improving.com> * Update to make relative time case-insensitive, and add corresponding unit tests. Signed-off-by: currantw <taylor.curran@improving.com> * Add a few more unit test cases. Signed-off-by: currantw <taylor.curran@improving.com> * Split pattern into smaller strings. Signed-off-by: currantw <taylor.curran@improving.com> * Add `relativeDateTimeFunction` to `SerializableUdf`, along with corresponding unit tests in `SerializableTimeUdfTest`. Add `mockito-inline` to dependencies for `ppl-spark-integration` to allow mocking of current datetime. Signed-off-by: currantw <taylor.curran@improving.com> * Fix dangling Javadoc Signed-off-by: currantw <taylor.curran@improving.com> * Initial implementation of `relative_timestamp` UDF. Signed-off-by: currantw <taylor.curran@improving.com> * Add integration tests, refactor to use Timestamp Signed-off-by: currantw <taylor.curran@improving.com> * Add documentation Signed-off-by: currantw <taylor.curran@improving.com> * Review comments: add more documentation, add ignored tests for earliest and latest. Signed-off-by: currantw <taylor.curran@improving.com> * Minor clean up Signed-off-by: currantw <taylor.curran@improving.com> * Update to use Instant and ZoneId. For some reason, timestamp can be returned, but output from `$CurrentTimestamp` is an `Instant` Signed-off-by: currantw <taylor.curran@improving.com> * Remove unused import Signed-off-by: currantw <taylor.curran@improving.com> * Address review comments Signed-off-by: currantw <taylor.curran@improving.com> * Address review comments Signed-off-by: currantw <taylor.curran@improving.com> * Update unit tests as per review comments Signed-off-by: currantw <taylor.curran@improving.com> * Remove duplicate documentation. Signed-off-by: currantw <taylor.curran@improving.com> * Fix failing IT Signed-off-by: currantw <taylor.curran@improving.com> --------- Signed-off-by: currantw <taylor.curran@improving.com>
Is your feature request related to a problem?
Support relative date-time strings similar to those supported in Splunk.
What solution would you like?
Implement support for relative date-time strings similar to those supported in Splunk, as described below. This should be integrated into the existing date-time implementation, such that date-time values that are declared using relative date-times can be compared and otherwise treated like any other date-time value.
Time Offset
The following time offset formats should be supported:
[+|-]<time_integer><offset_time_unit>
[+|-]<offset_time_unit>
now
The following offset time unit keywords should be supported:
s
,sec
,secs
,second
,seconds
m
,min
,mins
,minute
,minutes
h
,hr
,hrs
,hour
,hours
d
,day
,days
w
,wk
,week
,weeks
mon
,month
,months
q
,qtr
,qtrs
,quarter
,quarters
y
,yr
,yrs
,year
,years
Snap-to Time Units
In addition to the supported time unit keywords listed above, the following keywords representing the days of the week should be supported for snap-to times:
w0
,w7
w1
w2
w3
w4
w5
Sunday should be considered to be to be the first day of the week, such that
@w0
,@w7
,@w
, and@week
all correspond to the start of the previous Sunday. This is consistent with Splunk, but could be made configurable in the future if desired (i.e. so that Monday could be considered as the first day of the week).Examples
-60m
-h
+2wk
-1h@h
@d
-1d@w3
now
The following functionality will not be supported (but could be supported in the future):
@d+12h
).What alternatives have you considered?
None. See #957.
Do you have any additional context?
See #957.
The text was updated successfully, but these errors were encountered: