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

Added Support For Other Formats For GET_FORMAT Function #216

Conversation

GabeFernandez310
Copy link

Signed-off-by: GabeFernandez310 Gabriel.Fernandez@improving.com

Description

Adds the support for more formats for the get_format function to the OpenSearch SQL Plugin. Its implementation is aligned with the MySQL Documentation.

Issues Resolved

opensearch-project#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.

@GabeFernandez310 GabeFernandez310 requested a review from a team February 2, 2023 22:19
@codecov
Copy link

codecov bot commented Feb 2, 2023

Codecov Report

Merging #216 (e6e68f2) into integ-add-get_format-function-formats (4b3cdbb) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@                           Coverage Diff                            @@
##             integ-add-get_format-function-formats     #216   +/-   ##
========================================================================
  Coverage                                    98.36%   98.37%           
- Complexity                                    3643     3649    +6     
========================================================================
  Files                                          343      343           
  Lines                                         9017     9057   +40     
  Branches                                       585      585           
========================================================================
+ Hits                                          8870     8910   +40     
  Misses                                         142      142           
  Partials                                         5        5           
Flag Coverage Δ
sql-engine 98.37% <100.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
...c/main/java/org/opensearch/sql/expression/DSL.java 100.00% <100.00%> (ø)
...arch/sql/expression/datetime/DateTimeFunction.java 100.00% <100.00%> (ø)
...h/sql/expression/function/BuiltinFunctionName.java 100.00% <100.00%> (ø)
...pensearch/sql/sql/parser/AstExpressionBuilder.java 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@GabeFernandez310 GabeFernandez310 marked this pull request as draft February 2, 2023 23:15
@GabeFernandez310 GabeFernandez310 removed the request for review from a team February 2, 2023 23:15
.put("datetime", "usa", "%Y-%m-%d %H.%i.%s")
.put("timestamp", "usa", "%Y-%m-%d %H.%i.%s")
.build();
.put("date", "usa", "%m.%d.%Y")

Choose a reason for hiding this comment

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

Consider making DATE_USA and TIME_USA and then you can re-use it for datetime and tests.

Choose a reason for hiding this comment

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

Consider adding "usa" as a constant to re-use in tests

Choose a reason for hiding this comment

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

Consider adding "date" and "datetime", etc into a constant

Copy link
Author

Choose a reason for hiding this comment

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

I've decided against doing this for now. When I try to refactor the code, it ends up looking fairly messy because many of the formats have minor differences, so it results in harder-to-read code overall. I've also decided against using the constants and sharing them with the test code because if they are shared between this class and tests, many of the tests could still pass even if the format is wrong.

@GabeFernandez310
Copy link
Author

Check if formats can be implemented using ones from here https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#:~:text=Predefined%20Formatters

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
@GabeFernandez310 GabeFernandez310 force-pushed the dev-add-get_format-function-formats branch from e6bb0e1 to 67472fc Compare February 7, 2023 23:20
@GabeFernandez310 GabeFernandez310 marked this pull request as ready for review February 13, 2023 23:22
@GabeFernandez310 GabeFernandez310 merged commit aed78d0 into integ-add-get_format-function-formats Feb 13, 2023
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.

4 participants