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

Function str_to_date should work with two-digits year #2841

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

LantaoJin
Copy link
Member

@LantaoJin LantaoJin commented Jul 18, 2024

Description

str_to_date function in https://opensearch.org/docs/latest/search-plugins/sql/functions/#date-and-time does not work with two-digits year (RFC 822 date-time formatted).

SELECT str_to_date('23-Oct-17', '%d-%b-%y') returns 0017-10-23

With patching, above query returns 2017-10-23.

Issues Resolved

Resolves #2741

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.

Signed-off-by: Lantao Jin <ltjin@amazon.com>
@LantaoJin LantaoJin changed the title Function str_to_date should work with two-digits year Function str_to_date should work with two-digits year Jul 18, 2024
@LantaoJin LantaoJin added the bug Something isn't working label Jul 18, 2024
@LantaoJin LantaoJin marked this pull request as ready for review July 18, 2024 12:51
@@ -173,7 +173,7 @@ interface DateTimeFormatHandler {
.put("%T", "HH:mm:ss") // %T => HH:mm:ss
.put("%W", "EEEE") // %W => EEEE - Weekday name (Sunday..Saturday)
.put("%Y", "u") // %Y => yyyy - Year, numeric, 4 digits
.put("%y", "u") // %y => yy - Year, numeric, 2 digits
.put("%y", "uu") // %y => yy - Year, numeric, 2 digits
Copy link
Member Author

Choose a reason for hiding this comment

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

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 fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] str_to_date does not work with two-digits year
2 participants