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 TIMESTAMPADD Function To OpenSearch SQL Plugin #1451

Merged

Conversation

GabeFernandez310
Copy link
Contributor

Description

Adds the timestampadd() function to the OpenSearch SQL Plugin. Based off of the MySQL Implementation, but some changes were made due to the limitations of the plugin. Specifically, the return of this function is always a DATETIME. If an argument of type TIME is provided for the third argument, the DATE portion of the returned DATETIME will be filled in with values using the current date.

Examples:

opensearchsql> SELECT TIMESTAMPADD(MINUTE, 1, '2003-01-02 00:00:00');
fetched rows / total rows = 1/1
+--------------------------------------------------+
| TIMESTAMPADD(MINUTE, 1, '2003-01-02 00:00:00')   |
|--------------------------------------------------|
| 2003-01-02 00:01:00                              |
+--------------------------------------------------+
opensearchsql> SELECT TIMESTAMPADD(WEEK, 1, '2003-01-02 00:00:00');
fetched rows / total rows = 1/1
+------------------------------------------------+
| TIMESTAMPADD(WEEK, 1, '2003-01-02 00:00:00')   |
|------------------------------------------------|
| 2003-01-09 00:00:00                            |
+------------------------------------------------+
opensearchsql> SELECT TIMESTAMPADD(QUARTER, 1, '2003-01-02 00:00:00');
fetched rows / total rows = 1/1
+---------------------------------------------------+
| TIMESTAMPADD(QUARTER, 1, '2003-01-02 00:00:00')   |
|---------------------------------------------------|
| 2003-04-02 00:00:00                               |
+---------------------------------------------------+

Issues Resolved

#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.

Added Testing And Implementation for TIMESTAMPADD

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
@codecov-commenter
Copy link

codecov-commenter commented Mar 17, 2023

Codecov Report

Merging #1451 (80f6ce9) into main (bc39346) will increase coverage by 0.01%.
The diff coverage is 100.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@             Coverage Diff              @@
##               main    #1451      +/-   ##
============================================
+ Coverage     98.43%   98.44%   +0.01%     
- Complexity     3775     3806      +31     
============================================
  Files           343      343              
  Lines          9364     9449      +85     
  Branches        599      601       +2     
============================================
+ Hits           9217     9302      +85     
  Misses          142      142              
  Partials          5        5              
Flag Coverage Δ
sql-engine 98.44% <100.00%> (+0.01%) ⬆️

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 100.00% <100.00%> (ø)
...arch/sql/expression/datetime/DateTimeFunction.java 100.00% <100.00%> (ø)
...h/sql/expression/function/BuiltinFunctionName.java 100.00% <100.00%> (ø)
...pensearch/sql/expression/function/FunctionDSL.java 100.00% <100.00%> (ø)
...pensearch/sql/sql/parser/AstExpressionBuilder.java 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@GabeFernandez310 GabeFernandez310 marked this pull request as ready for review March 17, 2023 22:53
@GabeFernandez310 GabeFernandez310 requested a review from a team as a code owner March 17, 2023 22:53
@dai-chen dai-chen merged commit 7b83e50 into opensearch-project:main Mar 20, 2023
opensearch-trigger-bot bot pushed a commit that referenced this pull request Mar 20, 2023
* Add `TIMESTAMPADD` Function To OpenSearch SQL Plugin

Added Testing And Implementation for TIMESTAMPADD

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fixed Formatting

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

---------

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
(cherry picked from commit 7b83e50)
Yury-Fridlyand pushed a commit that referenced this pull request Mar 20, 2023
* Add `TIMESTAMPADD` Function To OpenSearch SQL Plugin

Added Testing And Implementation for TIMESTAMPADD

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

* Fixed Formatting

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>

---------

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
(cherry picked from commit 7b83e50)

Co-authored-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants