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

Merged
merged 2 commits into from
Dec 30, 2024

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.

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

@opensearch-trigger-bot
Copy link
Contributor

This PR is stalled because it has been open for 30 days with no activity.

@YANG-DB
Copy link
Member

YANG-DB commented Dec 29, 2024

@LantaoJin @dai-chen is this still relevant ?

@LantaoJin
Copy link
Member Author

@LantaoJin @dai-chen is this still relevant ?

I think the issue is still existing. let me update to latest code base.

@LantaoJin LantaoJin requested a review from noCharger as a code owner December 30, 2024 02:13
@LantaoJin
Copy link
Member Author

CI failure not related. Merging

@LantaoJin LantaoJin merged commit 4224f31 into opensearch-project:main Dec 30, 2024
11 of 15 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/sql/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/sql/backport-2.x
# Create a new branch
git switch --create backport/backport-2841-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 4224f318871d4bf8cb35764fb7f589530449a0de
# Push it to GitHub
git push --set-upstream origin backport/backport-2841-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/sql/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-2841-to-2.x.

LantaoJin added a commit to LantaoJin/search-plugins-sql that referenced this pull request Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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