-
Notifications
You must be signed in to change notification settings - Fork 180
Add STR_TO_DATE Function To The SQL Plugin
#1420
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 STR_TO_DATE Function To The SQL Plugin
#1420
Conversation
* Added Tests Signed-off-by: GabeFernandez310 <[email protected]> * Added Empty Implementation Signed-off-by: GabeFernandez310 <[email protected]> * Added Partially Working Implementation Signed-off-by: GabeFernandez310 <[email protected]> * Cleaned Up Implementation Signed-off-by: GabeFernandez310 <[email protected]> * Modified Implementation Signed-off-by: GabeFernandez310 <[email protected]> * Modified IT Test Signed-off-by: GabeFernandez310 <[email protected]> * Added Documentation Signed-off-by: GabeFernandez310 <[email protected]> * Added Unit Tests Signed-off-by: GabeFernandez310 <[email protected]> * Altered Implementation Signed-off-by: GabeFernandez310 <[email protected]> * Reworked Implementation To Always Return Datetime Signed-off-by: GabeFernandez310 <[email protected]> * Addressed PR Comments Signed-off-by: GabeFernandez310 <[email protected]> * Fixed Some Checkstyle Issues Signed-off-by: GabeFernandez310 <[email protected]> * Cleaned Implementation Signed-off-by: GabeFernandez310 <[email protected]> * Supported Function Properties Signed-off-by: GabeFernandez310 <[email protected]> * Fixed Checkstyle Signed-off-by: GabeFernandez310 <[email protected]> * Removed Unneeded Function Signed-off-by: GabeFernandez310 <[email protected]> * Cleaned Implementation and Added IT Test Signed-off-by: GabeFernandez310 <[email protected]> * Fixed Code Coverage and Implementation Signed-off-by: GabeFernandez310 <[email protected]> --------- Signed-off-by: GabeFernandez310 <[email protected]>
Codecov Report
📣 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 #1420 +/- ##
============================================
+ Coverage 98.39% 98.41% +0.01%
- Complexity 3716 3741 +25
============================================
Files 343 343
Lines 9160 9246 +86
Branches 582 596 +14
============================================
+ Hits 9013 9099 +86
Misses 142 142
Partials 5 5
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
acarbonetto
left a comment
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.
LGTM
core/src/main/java/org/opensearch/sql/expression/datetime/DateTimeFormatterUtil.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/opensearch/sql/expression/datetime/DateTimeFormatterUtil.java
Show resolved
Hide resolved
core/src/test/java/org/opensearch/sql/expression/datetime/StrToDateTest.java
Outdated
Show resolved
Hide resolved
22d2dea
Signed-off-by: GabeFernandez310 <[email protected]>
|
The backport to To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.x 2.x
# Navigate to the new working tree
cd .worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-1420-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 40336d4dd38bbd015564e03e4b16429b59c6412f
# Push it to GitHub
git push --set-upstream origin backport/backport-1420-to-2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.xThen, create a pull request where the |
* Add `STR_TO_DATE` Function To The SQL Plugin. * Added Tests Signed-off-by: GabeFernandez310 <[email protected]> * Added Empty Implementation Signed-off-by: GabeFernandez310 <[email protected]> * Added Partially Working Implementation Signed-off-by: GabeFernandez310 <[email protected]> * Cleaned Up Implementation Signed-off-by: GabeFernandez310 <[email protected]> * Modified Implementation Signed-off-by: GabeFernandez310 <[email protected]> * Modified IT Test Signed-off-by: GabeFernandez310 <[email protected]> * Added Documentation Signed-off-by: GabeFernandez310 <[email protected]> * Added Unit Tests Signed-off-by: GabeFernandez310 <[email protected]> * Altered Implementation Signed-off-by: GabeFernandez310 <[email protected]> * Reworked Implementation To Always Return Datetime Signed-off-by: GabeFernandez310 <[email protected]> * Addressed PR Comments Signed-off-by: GabeFernandez310 <[email protected]> * Fixed Some Checkstyle Issues Signed-off-by: GabeFernandez310 <[email protected]> * Cleaned Implementation Signed-off-by: GabeFernandez310 <[email protected]> * Supported Function Properties Signed-off-by: GabeFernandez310 <[email protected]> * Fixed Checkstyle Signed-off-by: GabeFernandez310 <[email protected]> * Removed Unneeded Function Signed-off-by: GabeFernandez310 <[email protected]> * Cleaned Implementation and Added IT Test Signed-off-by: GabeFernandez310 <[email protected]> * Fixed Code Coverage and Implementation Signed-off-by: GabeFernandez310 <[email protected]> --------- Signed-off-by: GabeFernandez310 <[email protected]> * Cleaned Implementation Signed-off-by: GabeFernandez310 <[email protected]> --------- Signed-off-by: GabeFernandez310 <[email protected]> (cherry picked from commit 40336d4)
* Add `STR_TO_DATE` Function To The SQL Plugin. * Added Tests Signed-off-by: GabeFernandez310 <[email protected]> * Added Empty Implementation Signed-off-by: GabeFernandez310 <[email protected]> * Added Partially Working Implementation Signed-off-by: GabeFernandez310 <[email protected]> * Cleaned Up Implementation Signed-off-by: GabeFernandez310 <[email protected]> * Modified Implementation Signed-off-by: GabeFernandez310 <[email protected]> * Modified IT Test Signed-off-by: GabeFernandez310 <[email protected]> * Added Documentation Signed-off-by: GabeFernandez310 <[email protected]> * Added Unit Tests Signed-off-by: GabeFernandez310 <[email protected]> * Altered Implementation Signed-off-by: GabeFernandez310 <[email protected]> * Reworked Implementation To Always Return Datetime Signed-off-by: GabeFernandez310 <[email protected]> * Addressed PR Comments Signed-off-by: GabeFernandez310 <[email protected]> * Fixed Some Checkstyle Issues Signed-off-by: GabeFernandez310 <[email protected]> * Cleaned Implementation Signed-off-by: GabeFernandez310 <[email protected]> * Supported Function Properties Signed-off-by: GabeFernandez310 <[email protected]> * Fixed Checkstyle Signed-off-by: GabeFernandez310 <[email protected]> * Removed Unneeded Function Signed-off-by: GabeFernandez310 <[email protected]> * Cleaned Implementation and Added IT Test Signed-off-by: GabeFernandez310 <[email protected]> * Fixed Code Coverage and Implementation Signed-off-by: GabeFernandez310 <[email protected]> --------- Signed-off-by: GabeFernandez310 <[email protected]> * Cleaned Implementation Signed-off-by: GabeFernandez310 <[email protected]> --------- Signed-off-by: GabeFernandez310 <[email protected]> (cherry picked from commit 40336d4)
Description
Adds the
str_to_datefunction to the SQL plugin. The function takes two arguments, an input string and a format string. The format string contains string format specifiers which describe how the characters in the input string are parsed to aDATETIME. Based off of MySQL, but differs in some areas due to the limitations of the plugin and Java's built-in DatetimeFormatter. Specifically, the format string used must exactly match the string being parsed, and any dates/times with 0 for the year/month/day will return NULL since these fields must be valid for Java LocalDate/LocalTime/LocalDatetime. The arguments must have enough information to build aDATE,TIME, orDATETIME.Example:
SELECT str_to_date("May 1, 2013", "%M %d, %Y")->2013-05-01 00:00:00SELECT str_to_date("9,23,11", "%h,%i,%s")->0001-01-01 09:23:11Issues Resolved
#722
Check List
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.