Skip to content
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 UTC_DATE, UTC_TIME, UTC_TIMESTAMP #187

Conversation

MitchellGale
Copy link

Description

Adds functionality for UTC_TIME, UTC_DATE and UTC_TIMESTAMP functions.

UTC_TIME - Returns current UTC time in HH:mm:ss time format.
UTC_DATE - Returns current UTC date in uuuu-MM-dd date format.
UTC_TIMESTAMP - Returns current UTC Date/time in uuuu-MM-dd HH:mm:ss date format.

Example use cases:

opensearchsql> SELECT utc_timestamp(), utc_date(), utc_time();                                                                                                                     
fetched rows / total rows = 1/1
+---------------------+--------------+--------------+
| utc_timestamp()     | utc_date()   | utc_time()   |
|---------------------+--------------+--------------|
| 2022-12-09 19:40:54 | 2022-12-09   | 19:40:54     |
+---------------------+--------------+--------------+

Issues Resolved

opensearch-project#722

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --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.

Signed-off-by: MitchellGale-BitQuill <mitchellg@bitquilltech.com>
Signed-off-by: MitchellGale-BitQuill <mitchellg@bitquilltech.com>
Signed-off-by: MitchellGale-BitQuill <mitchellg@bitquilltech.com>
@codecov
Copy link

codecov bot commented Dec 9, 2022

Codecov Report

Merging #187 (3648144) into Integ-UTC_DATE_TIME_TIMESTAMP_LIKENOW (354e843) will decrease coverage by 35.54%.
The diff coverage is n/a.

@@                             Coverage Diff                              @@
##             Integ-UTC_DATE_TIME_TIMESTAMP_LIKENOW     #187       +/-   ##
============================================================================
- Coverage                                    98.31%   62.76%   -35.55%     
============================================================================
  Files                                          348       10      -338     
  Lines                                         8707      658     -8049     
  Branches                                       555      119      -436     
============================================================================
- Hits                                          8560      413     -8147     
- Misses                                         142      192       +50     
- Partials                                         5       53       +48     
Flag Coverage Δ
query-workbench 62.76% <ø> (?)
sql-engine ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...c/main/java/org/opensearch/sql/expression/DSL.java
...arch/sql/expression/datetime/DateTimeFunction.java
...h/sql/expression/function/BuiltinFunctionName.java
.../planner/logical/rules/MergeFilterAndRelation.java
...n/java/org/opensearch/sql/utils/DateTimeUtils.java
...g/opensearch/sql/planner/logical/LogicalLimit.java
.../sql/planner/physical/PhysicalPlanNodeVisitor.java
...ch/sql/opensearch/client/OpenSearchNodeClient.java
...rch/sql/opensearch/response/agg/TopHitsParser.java
...search/sql/expression/datetime/CalendarLookup.java
... and 348 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link

@Yury-Fridlyand Yury-Fridlyand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, update ppl/src/test/java/org/opensearch/sql/ppl/antlr/NowLikeFunctionParserTest.java and sql/src/test/java/org/opensearch/sql/sql/parser/AstNowLikeFunctionTest.java too

Signed-off-by: MitchellGale-BitQuill <mitchellg@bitquilltech.com>
Signed-off-by: MitchellGale-BitQuill <mitchellg@bitquilltech.com>
Copy link

@MaxKsyunz MaxKsyunz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple minor style comments but everything else LGTM.

private DefaultFunctionResolver utc_time() {
return define(BuiltinFunctionName.UTC_TIME.getName(),
implWithProperties(functionProperties
-> DateTimeFunction.exprUtcTime(functionProperties), TIME));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-> DateTimeFunction.exprUtcTime(functionProperties), TIME));
->exprUtcTime(functionProperties), TIME));

Doesn't this comment apply here as well?

private DefaultFunctionResolver utc_timestamp() {
return define(BuiltinFunctionName.UTC_TIMESTAMP.getName(),
implWithProperties(functionProperties
-> DateTimeFunction.exprUtcTimeStamp(functionProperties), DATETIME));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-> DateTimeFunction.exprUtcTimeStamp(functionProperties), DATETIME));
->exprUtcTimeStamp(functionProperties), DATETIME));

Doesn't this comment apply here as well?

Signed-off-by: MitchellGale-BitQuill <mitchellg@bitquilltech.com>
@MitchellGale MitchellGale merged commit 2d48ba0 into Integ-UTC_DATE_TIME_TIMESTAMP_LIKENOW Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants