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

Minor clean up of datetime and other classes #198

Merged
merged 19 commits into from
Jan 30, 2023

Conversation

MitchellGale
Copy link

@MitchellGale MitchellGale commented Dec 22, 2022

Description

Clean up lexer to make future changes easier. Make changes to documentation and code to make cleaner.

  • Groom ANTLR grammar files to make future changes easier.
  • Fix EqualsAndHashCode compilation warnings
Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object. If this is intentional, add '@EqualsAndHashCode(callSuper=false)' to your type.
  • Move ExprTimestampValue.ZONE constant to DateTimeUtils
  • Move ExprDatetimeValue formatter to DateTimeFormatters
  • Sort alphabetically functions in DateTimeFunction and MathematicalFunction
  • Replace FunctionDSL import by static imports to simplify code
  • Remove tests for NULL and MISSING values
  • Add validation for non-zero divider
  • Remove Environment mock from some unit tests, because it is not needed anymore
  • Groom docs to eliminate rst validator warnings
  • Add doctests for some functions
  • Make IT for now-like functions truly parametrized
  • Rename some PPL grammar entities to be consistent with SQL ones

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.

@codecov

This comment was marked as spam.

@MitchellGale MitchellGale changed the base branch from Integ-cleanUp to Integ-clean_up December 22, 2022 05:30
@MitchellGale MitchellGale changed the base branch from Integ-clean_up to Integ-cleanUp December 22, 2022 05:30
@MitchellGale MitchellGale changed the base branch from Integ-cleanUp to Integ-cleanup2 December 22, 2022 05:31
@MitchellGale MitchellGale changed the base branch from Integ-cleanup2 to integ-cleanupcode December 22, 2022 05:39
MitchellGale and others added 9 commits January 16, 2023 10:57
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]>
@Yury-Fridlyand Yury-Fridlyand marked this pull request as ready for review January 17, 2023 19:50
@@ -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");

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?

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);

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.

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());

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.

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') |

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?

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.

@@ -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)

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");

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?

@Yury-Fridlyand Yury-Fridlyand merged commit a6b4f48 into integ-cleanupcode Jan 30, 2023
@Yury-Fridlyand Yury-Fridlyand deleted the dev-DateTime_cleaning branch January 30, 2023 21:05
Yury-Fridlyand added a commit that referenced this pull request Jan 30, 2023
Signed-off-by: MitchellGale-BitQuill <[email protected]>
Co-authored-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Yury-Fridlyand added a commit that referenced this pull request Feb 7, 2023
Signed-off-by: MitchellGale-BitQuill <[email protected]>
Co-authored-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Yury-Fridlyand added a commit that referenced this pull request Feb 14, 2023
Signed-off-by: MitchellGale-BitQuill <[email protected]>
Co-authored-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
Yury-Fridlyand added a commit that referenced this pull request Apr 18, 2023
Signed-off-by: MitchellGale-BitQuill <[email protected]>
Co-authored-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
MaxKsyunz pushed a commit that referenced this pull request Apr 21, 2023
…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]>
acarbonetto pushed a commit that referenced this pull request Apr 28, 2023
…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]>
Yury-Fridlyand added a commit that referenced this pull request May 1, 2023
…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]>
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.

6 participants