-
Notifications
You must be signed in to change notification settings - Fork 0
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
#246
Add TIMESTAMPADD
Function To OpenSearch SQL Plugin
#246
Conversation
Signed-off-by: GabeFernandez310 <[email protected]>
Signed-off-by: GabeFernandez310 <[email protected]>
Signed-off-by: GabeFernandez310 <[email protected]>
Signed-off-by: GabeFernandez310 <[email protected]>
Signed-off-by: GabeFernandez310 <[email protected]>
Signed-off-by: GabeFernandez310 <[email protected]>
Signed-off-by: GabeFernandez310 <[email protected]>
Signed-off-by: GabeFernandez310 <[email protected]>
Signed-off-by: GabeFernandez310 <[email protected]>
Codecov Report
@@ Coverage Diff @@
## integ-add-timestampadd-function #246 +/- ##
==================================================================
Coverage ? 98.44%
Complexity ? 3806
==================================================================
Files ? 343
Lines ? 9449
Branches ? 601
==================================================================
Hits ? 9302
Misses ? 142
Partials ? 5
Flags with carried forward coverage won't be shown. Click here to find out more. 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
core/src/main/java/org/opensearch/sql/expression/datetime/DateTimeFunction.java
Show resolved
Hide resolved
"2021-01-07 23:59:59"), | ||
|
||
//Test remaining interval types | ||
Arguments.of("MICROSECOND", 1, new ExprStringValue("2003-01-02 00:00:00"), |
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.
Need to test adding a month (see special cases given in example on MySQL doc)
Test negative values and values > 1[00] too
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.
Yes. -1 Microsecond from 2000-01-01 00:00:00
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.
Added in 77226ba
core/src/main/java/org/opensearch/sql/expression/datetime/DateTimeFunction.java
Outdated
Show resolved
Hide resolved
return (functionProperties, v1, v2, v3) -> { | ||
if (v1.isMissing() || v2.isMissing() || v3.isMissing()) { | ||
return ExprValueUtils.missingValue(); | ||
} else if (v1.isNull() || v2.isNull() || v3.isNull()) { |
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.
else not needed
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.
Changed in 77226ba
return ExprValueUtils.missingValue(); | ||
} else if (v1.isNull() || v2.isNull() || v3.isNull()) { | ||
return ExprValueUtils.nullValue(); | ||
} else { |
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.
else not needed
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.
Changed in 77226ba
* @param returnType return type. | ||
* @param args1Type first argument type. | ||
* @param args2Type second argument type. | ||
* @param args3Type second argument type. |
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.
* @param args3Type second argument type. | |
* @param args3Type third argument type. |
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.
Changed in 77226ba
"2021-01-07 23:59:59"), | ||
|
||
//Test remaining interval types | ||
Arguments.of("MICROSECOND", 1, new ExprStringValue("2003-01-02 00:00:00"), |
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.
Yes. -1 Microsecond from 2000-01-01 00:00:00
@Test | ||
public void testAddingDatePartToTime() { | ||
String interval = "WEEK"; | ||
int addedInterval = 1; |
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.
Add tests with interval != 1.
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.
Changed in 77226ba
Signed-off-by: GabeFernandez310 <[email protected]>
Signed-off-by: GabeFernandez310 <[email protected]>
Signed-off-by: GabeFernandez310 <[email protected]>
Signed-off-by: GabeFernandez310 <[email protected]>
Signed-off-by: GabeFernandez310 <[email protected]>
Signed-off-by: GabeFernandez310 <[email protected]>
"2003-01-02 00:01:00"), | ||
Arguments.of("WEEK", 1, new ExprDatetimeValue("2003-01-02 00:00:00"), | ||
"2003-01-09 00:00:00"), | ||
//timstamp |
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.
Fix spelling. Add white space between groups of tests.
//timstamp | |
//Timestamp |
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 aDATETIME
. If an argument of typeTIME
is provided for the third argument, theDATE
portion of the returnedDATETIME
will be filled in with values using the current date.Examples:
Issues 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.