-
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
#957 Implement earliest
and latest
functions
#1018
#957 Implement earliest
and latest
functions
#1018
Conversation
…st and latest. Signed-off-by: currantw <[email protected]>
Signed-off-by: currantw <[email protected]>
Signed-off-by: currantw <[email protected]>
Signed-off-by: currantw <[email protected]>
Signed-off-by: currantw <[email protected]>
EARLIEST: 'EARLIEST'; | ||
EARLIEST_TIME: 'EARLIEST_TIME'; | ||
LATEST: 'LATEST'; | ||
LATEST_TIME: 'LATEST_TIME'; |
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.
These aggregation commands don't appear to have ever been implemented. They are not used, referenced, or documented anywhere outside the auto-generated Antlr modules, that I can find. Moreover, I think that their functionality (as best as I can guess from the name, since they aren't documented) can just be accomplished using the existing min
and max
functions?
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.
are there spark issues that refer to this syntax? if so should mention that they are no longer relevant
or does sql has these implemented? If so might want to create future issues to implement this as we are striving for feature parity.
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.
are there spark issues that refer to this syntax? if so should mention that they are no longer relevant
Good idea. I searched and didn't find anything.
or does sql has these implemented? If so might want to create future issues to implement this as we are striving for feature parity.
OpenSearch SQL does not appear to have these implemented either, and I similarly wasn't able to find any GitHub issues that made mentioned of it.
@YANG-DB I assume it also makes sense to remove this syntax from OpenSearch SQL for parity? Should I raise an issue and create a (tiny) PR for this?
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.
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.
Update: here is the pull request.
ppl-spark-integration/src/main/java/org/opensearch/sql/expression/function/SerializableUdf.java
Show resolved
Hide resolved
...ation/scala/org/opensearch/flint/spark/ppl/FlintSparkPPLBuiltInDateTimeFunctionITSuite.scala
Show resolved
Hide resolved
...spark-integration/src/main/java/org/opensearch/sql/ppl/utils/BuiltinFunctionTransformer.java
Outdated
Show resolved
Hide resolved
Signed-off-by: currantw <[email protected]>
|
||
#### **earliest** | ||
[See additional function details](functions/ppl-datetime#earliest) | ||
- `source = table | where earliest("-1wk", timestamp)` |
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.
in the case where earliest is interpreted as
timestamp >= now() - 1s
, depend on when the now() is resolved, it may produce insonsistent result?
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.
I don't believe so. Relative timestamp are based on calls to CurrentTimestamp
(see org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
). If you look at the documentation for CurrentTimestamp
, it says that:
Returns the current timestamp at the start of query evaluation. All calls of current_timestamp within the same query return the same value.
So now()
, relative_timestamp("now")
, earliest("now", timestamp)
, latest("now", timestamp)
and current_timestamp
should all return consistent results within the same query. I tested this out manually as well to verify (i.e. repeated calls to these methods within the same query return the same now
timestamp, down to the millisecond).
Signed-off-by: currantw [email protected]
Description
Implements
earliest
andlatest
relative date time functions in PPL.Related Issues
Resolves #957
Check List
PPL-Example-Commands.md
ppl-datetime.md
ppl-where-command.md
TimeUtilsTest
SerializableTimeUdfTest
FlintSparkPPLBuiltInDateTimeFunctionITSuite
--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.