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 maketime and makedate datetime functions #755

Merged
merged 1 commit into from
Aug 16, 2022

Conversation

Yury-Fridlyand
Copy link
Collaborator

Signed-off-by: Yury Fridlyand yuryf@bitquilltech.com

Description

  • maketime, references: one two
    • Supports any values in range 00:00:00.0 - 23:59:59.(9);
    • All arguments are double, but hour and minute are rounded (as MySQL works);
    • Fraction second part is kept;
    • NULL values causes NULL result;
    • Unlike MySQL, negative values, and hour > 23 are not supported. Implementation of that requires big changes.
  • makedate, references one two
    • All arguments are double, but rounded (as MySQL works);
    • Zero year interpreted as 2000 (as MySQL works);
    • NULL values causes NULL result;
    • day < 1 causes NULL result;
    • day > 365/366 causes switching to the next year.

Implementation details

Functions have 2 implementations:

  • easier
  • faster

I used easier one, but faster one used in unit tests. Could be swapped.

According to MySQL both functions accept double values. Arguments which are not supposed to have fraction parts (e.g. hour, year) are rounded.

maketime doesn't support range of +-838 hours, it is limited by 24 hour clock time. Implementation of that requires big changes.

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.

@Yury-Fridlyand Yury-Fridlyand requested a review from a team as a code owner August 12, 2022 18:55
@codecov-commenter
Copy link

codecov-commenter commented Aug 12, 2022

Codecov Report

Merging #755 (00a2dca) into main (deececb) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##               main     #755      +/-   ##
============================================
+ Coverage     94.83%   94.84%   +0.01%     
- Complexity     2898     2908      +10     
============================================
  Files           287      287              
  Lines          7803     7825      +22     
  Branches        568      571       +3     
============================================
+ Hits           7400     7422      +22     
  Misses          349      349              
  Partials         54       54              
Flag Coverage Δ
query-workbench 62.76% <ø> (ø)
sql-engine 97.79% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...arch/sql/expression/datetime/DateTimeFunction.java 100.00% <100.00%> (ø)
...h/sql/expression/function/BuiltinFunctionName.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.

@dai-chen
Copy link
Collaborator

Could you rebase your branch? There seems many irrelevant changes from previous commit. Thanks!

Signed-off-by: Yury Fridlyand <yuryf@bitquilltech.com>
@Yury-Fridlyand Yury-Fridlyand force-pushed the integ-make-time-n-date branch from 1b6877d to 00a2dca Compare August 12, 2022 22:01
@Yury-Fridlyand
Copy link
Collaborator Author

Could you rebase your branch? There seems many irrelevant changes from previous commit. Thanks!

Should be ok now.

Copy link
Collaborator

@dai-chen dai-chen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes!

@dai-chen dai-chen merged commit 9f602c3 into opensearch-project:main Aug 16, 2022
opensearch-trigger-bot bot pushed a commit that referenced this pull request Aug 17, 2022
Signed-off-by: Yury Fridlyand <yuryf@bitquilltech.com>

Signed-off-by: Yury Fridlyand <yuryf@bitquilltech.com>
(cherry picked from commit 9f602c3)
@Yury-Fridlyand Yury-Fridlyand deleted the integ-make-time-n-date branch September 9, 2022 21:12
@MaxKsyunz MaxKsyunz added enhancement New feature or request SQL PPL Piped processing language labels Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x enhancement New feature or request PPL Piped processing language SQL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants