-
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
Minor clean up of datetime and other classes #198
Conversation
This comment was marked as spam.
This comment was marked as spam.
Signed-off-by: MitchellGale-BitQuill <[email protected]>
Signed-off-by: MitchellGale-BitQuill <[email protected]>
Signed-off-by: MitchellGale-BitQuill <[email protected]>
Signed-off-by: MitchellGale-BitQuill <[email protected]>
Signed-off-by: MitchellGale-BitQuill <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
56a89a7
to
f3ea329
Compare
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
@@ -151,4 +151,6 @@ public static LocalDate extractDate(ExprValue value, | |||
? ((ExprTimeValue) value).dateValue(functionProperties) | |||
: value.dateValue(); | |||
} | |||
|
|||
public static final ZoneId UTC_ZONE_ID = ZoneId.of("UTC"); |
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.
Should constants be at the beginning or at the end?
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.
Do we also want to "encourage" private functions to be defined after public functions?
assertEquals("adddate(\"2020-08-26\", interval(1, \"day\"))", expr.toString()); | ||
|
||
when(nullRef.type()).thenReturn(DATE); |
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'm curious on what these removed asserts actually do. I noticed them as I've been working on DateTime stuff, but I don't actually know what they are supposed to be testing.
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.
They handle nullMissingHandling
, which is tested in FunctionDSLnullMissingHandlingTest
. Thanks Max by adding those tests.
This specific line mocks type of nullRef
to let repository pick a function signature.
The null/missing validation actually doesn't test the function and it is not needed to repeat it 100500 times for each function.
@@ -444,10 +319,6 @@ private void testDayOfMonthWithUnderscores(FunctionExpression dateExpression, in | |||
|
|||
@Test | |||
public void dayOfMonthWithUnderscores() { | |||
lenient().when(nullRef.valueOf(env)).thenReturn(nullValue()); |
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 will probably make my PR 204 for time_format
conflict. Is it safe to checkout this file into my PR, or should I wait until this is merged upstream and rebase before making my PR for time_format
upstream.
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.
It doesn't matter which PR goes first, but we have to rebase second one once first merged and fix conflicts.
| '13:14:15.012345' | '1998-Jan-31st 01:14:15 PM' | | ||
+-----------------------------------------------+----------------------------------------------------------------+ | ||
+------------------------------------------------------+-----------------------------------------------------------------------+ | ||
| DATE_FORMAT('1998-01-31 13:14:15.012345', '%T.%f') | DATE_FORMAT(TIMESTAMP('1998-01-31 13:14:15.012345'), '%Y-%b-%D %r') | |
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 have also changed this in my PR. Should I revert my changes?
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.
No!
That would be interpreted as merge conflict, which is easy to resolve.
...ava/org/opensearch/sql/opensearch/storage/script/filter/lucene/relevance/RelevanceQuery.java
Show resolved
Hide resolved
…d on a doctest cluster. Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
@@ -40,7 +36,7 @@ public class ExprTimestampValue extends AbstractExprValue { | |||
public ExprTimestampValue(String timestamp) { | |||
try { | |||
this.timestamp = LocalDateTime.parse(timestamp, DATE_TIME_FORMATTER_VARIABLE_NANOS) | |||
.atZone(ZONE) | |||
.atZone(UTC_ZONE_ID) |
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.
Is there any interest in including a default time zone in the functionalProperties object?
@@ -151,4 +151,6 @@ public static LocalDate extractDate(ExprValue value, | |||
? ((ExprTimeValue) value).dateValue(functionProperties) | |||
: value.dateValue(); | |||
} | |||
|
|||
public static final ZoneId UTC_ZONE_ID = ZoneId.of("UTC"); |
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.
Do we also want to "encourage" private functions to be defined after public functions?
Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: MitchellGale-BitQuill <[email protected]> Co-authored-by: Yury-Fridlyand <[email protected]> Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: MitchellGale-BitQuill <[email protected]> Co-authored-by: Yury-Fridlyand <[email protected]> Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: MitchellGale-BitQuill <[email protected]> Co-authored-by: Yury-Fridlyand <[email protected]> Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: MitchellGale-BitQuill <[email protected]> Co-authored-by: Yury-Fridlyand <[email protected]> Signed-off-by: Yury-Fridlyand <[email protected]>
…ct#1310) * Minor clean up of datetime and other classes (#198) --------- Signed-off-by: MitchellGale-BitQuill <[email protected]> Signed-off-by: Yury-Fridlyand <[email protected]>
…ct#1310) * Minor clean up of datetime and other classes (#198) --------- Signed-off-by: MitchellGale-BitQuill <[email protected]> Signed-off-by: Yury-Fridlyand <[email protected]>
…ct#1310) (opensearch-project#1567) * Minor clean up of datetime and other classes (#198) --------- Signed-off-by: MitchellGale-BitQuill <[email protected]> Signed-off-by: Yury-Fridlyand <[email protected]> (cherry picked from commit bc29a8a) Co-authored-by: Yury-Fridlyand <[email protected]>
Description
Clean up lexer to make future changes easier. Make changes to documentation and code to make cleaner.
EqualsAndHashCode
compilation warningsExprTimestampValue.ZONE
constant toDateTimeUtils
ExprDatetimeValue
formatter toDateTimeFormatters
DateTimeFunction
andMathematicalFunction
FunctionDSL
import by static imports to simplify codeNULL
andMISSING
valuesEnvironment
mock from some unit tests, because it is not needed anymorerst
validator warningsnow
-like functions truly parametrizedCheck 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.