Repository navigation
Add earliest and latest in condition function - #3640
Conversation
Signed-off-by: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
|
dai-chen
left a comment
There was a problem hiding this comment.
In SPL doc, these functions are applied to _raw field, but in our impl it's just an alias of min/max?
Signed-off-by: xinyual <[email protected]>
Add the doc. |
Signed-off-by: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
| "1970-01-18 20:22:32", | ||
| "2018-08-19 00:00:00")); |
There was a problem hiding this comment.
I am afraid the current implementation may be wrong, the current implementation treat the earliest and latest as window function with default window frame. IMO, the behavior is odd. Please check again if they require to use other window frame instead default.
There was a problem hiding this comment.
@xinyual does spark-ppl support eventstats earliest(birthdate), latest(birthdate), if not, can we decide later, and only support it as condition function?
From user perspective, It is alias of min/max function, not impact usability.
There was a problem hiding this comment.
Spark-ppl only supports it as condition function. Currently I forbid them as window/aggregation in the latest code.
|
|
||
| Usage: earliest(relative_string, field) returns true if the field is after transferring the relative_string. | ||
|
|
||
| relative_string: |
There was a problem hiding this comment.
-
Does relative_string follow RELATIVE_TIMESTAMP or OpenSearch date math?
-
relative_string should include a clear definition of the supported time modifiers.
There was a problem hiding this comment.
- Does relative_string follow RELATIVE_TIMESTAMP or OpenSearch date math?
Yes.
- relative_string should include a clear definition of the supported time modifiers.
@xinyual add link to https://github.com/opensearch-project/opensearch-spark/blob/main/docs/ppl-lang/functions/ppl-datetime.md#relative_timestamp here.
| ZonedDateTime candidateDatetime = ZonedDateTime.ofInstant(candidate, clock.getZone()); | ||
| ZonedDateTime latest = | ||
| getRelativeZonedDateTime( | ||
| expression, ZonedDateTime.ofInstant(clock.instant(), clock.getZone())); | ||
| return latest.isAfter(candidateDatetime); |
There was a problem hiding this comment.
In case all timestamp use same timezone, this PR actually does not have similar issue as #3725?
Signed-off-by: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
LantaoJin
left a comment
There was a problem hiding this comment.
LGTM once doc comment addressed.
| public static final UDFOperandMetadata DATE_OR_TIMESTAMP_OR_STRING = | ||
| UDFOperandMetadata.wrap( | ||
| (CompositeOperandTypeChecker) OperandTypes.DATE_OR_TIMESTAMP.or(OperandTypes.STRING)); | ||
| public static final UDFOperandMetadata STRING_DATE_OR_TIMESTAMP = |
There was a problem hiding this comment.
minor: change to STRING_OR_TIMESTAMP
There was a problem hiding this comment.
Already rename to STRING_TIMESTMAP, which means accept (STRING, TIMESTAMP)
|
|
||
| Usage: earliest(relative_string, field) returns true if the field is after transferring the relative_string. | ||
|
|
||
| relative_string: |
There was a problem hiding this comment.
- Does relative_string follow RELATIVE_TIMESTAMP or OpenSearch date math?
Yes.
- relative_string should include a clear definition of the supported time modifiers.
@xinyual add link to https://github.com/opensearch-project/opensearch-spark/blob/main/docs/ppl-lang/functions/ppl-datetime.md#relative_timestamp here.
Signed-off-by: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
* add earliest and latest Signed-off-by: xinyual <[email protected]> * add more ITs Signed-off-by: xinyual <[email protected]> * reuse max/min Signed-off-by: xinyual <[email protected]> * revert useless change Signed-off-by: xinyual <[email protected]> * add doc Signed-off-by: xinyual <[email protected]> * fix do Signed-off-by: xinyual <[email protected]> * fix doctest Signed-off-by: xinyual <[email protected]> * add earliest and latest as two condition function Signed-off-by: xinyual <[email protected]> * fix relative string Signed-off-by: xinyual <[email protected]> * add more IT Signed-off-by: xinyual <[email protected]> * change doc Signed-off-by: xinyual <[email protected]> * update doc Signed-off-by: xinyual <[email protected]> * update doc Signed-off-by: xinyual <[email protected]> * update doc Signed-off-by: xinyual <[email protected]> * add more doc Signed-off-by: xinyual <[email protected]> * update to utc_timestamp Signed-off-by: xinyual <[email protected]> * remove useless change Signed-off-by: xinyual <[email protected]> * update the doc Signed-off-by: xinyual <[email protected]> * forbidden the earliest/latest in aggregation/window function Signed-off-by: xinyual <[email protected]> * forbid IT Signed-off-by: xinyual <[email protected]> * revert doc Signed-off-by: xinyual <[email protected]> * add type checker Signed-off-by: xinyual <[email protected]> * revert useless change Signed-off-by: xinyual <[email protected]> * add doc Signed-off-by: xinyual <[email protected]> * add link Signed-off-by: xinyual <[email protected]> * apply spotless Signed-off-by: xinyual <[email protected]> --------- Signed-off-by: xinyual <[email protected]>
Description
This pr add latest/earliest as two condition function, it will calculate the relative time according to relative string and current time.
Related Issues
Resolves #[Issue number to be closed when this PR is merged]
#3639
Check List
--signoff.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.