Add The `TO_SECONDS` Function To The SQL Plugin by GabeFernandez310 · Pull Request #1419 · opensearch-project/sql · GitHub
Skip to content

Add The TO_SECONDS Function To The SQL Plugin#1419

Merged
dai-chen merged 4 commits into
opensearch-project:mainfrom
Bit-Quill:integ-add-to_seconds-function
Mar 16, 2023
Merged

Add The TO_SECONDS Function To The SQL Plugin#1419
dai-chen merged 4 commits into
opensearch-project:mainfrom
Bit-Quill:integ-add-to_seconds-function

Conversation

@GabeFernandez310

Copy link
Copy Markdown
Contributor

Description

Adds the to_seconds function to the SQL plugin. Takes a DATE/TIME/DATETIME/TIMESTAMP/STRING/INTEGER representing a point in time, and converts it to seconds since the year 0. This function is based off of MySQL. For arguments of type TIME, the function takes the current date at the given time. For INTEGER, the integer is parsed as a date (e.g. 950501 == 1995-05-01).

Examples:
SELECT TO_SECONDS(950501); -> 62966505600
SELECT TO_SECONDS('2009-11-29'); -> 63426672000
SELECT TO_SECONDS('2009-11-29 13:43:32'); -> 63426721412

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.

* Added Basic Tests

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

* Added IT Test

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

* Added Implementation

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

* Changed Integration Tests

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

* Added Test For Time Type

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

* Added Documentation

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

* Addressed PR Comments

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

* Fixed Docs and Implementation

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

* Fixed Checkstyle

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

* Changed DateTimeFormatter Priority

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

* Added More Formatters

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

* Updated Docs

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

* Reworked Implementation For Formatters

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

* Cleanup

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

* Added Test

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

* Fixed Implementation And Code Coverage

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

* Changed getFormatter Function

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

* Added Comments

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

---------

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
@GabeFernandez310 GabeFernandez310 requested a review from a team as a code owner March 9, 2023 22:38
@codecov-commenter

codecov-commenter commented Mar 9, 2023

Copy link
Copy Markdown

acarbonetto
acarbonetto previously approved these changes Mar 13, 2023

@acarbonetto acarbonetto left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

Yury-Fridlyand
Yury-Fridlyand previously approved these changes Mar 15, 2023
Comment thread core/src/test/java/org/opensearch/sql/expression/datetime/ToSecondsTest.java Outdated
Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
@dai-chen dai-chen merged commit d38a6ec into opensearch-project:main Mar 16, 2023
@opensearch-trigger-bot

Copy link
Copy Markdown
Contributor

GabeFernandez310 added a commit to Bit-Quill/opensearch-project-sql that referenced this pull request Mar 16, 2023
)

* Add The `TO_SECONDS` Function To The SQL Plugin (#232)

* Added Basic Tests

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

* Added IT Test

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

* Added Implementation

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

* Changed Integration Tests

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

* Added Test For Time Type

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

* Added Documentation

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

* Addressed PR Comments

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

* Fixed Docs and Implementation

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

* Fixed Checkstyle

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

* Changed DateTimeFormatter Priority

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

* Added More Formatters

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

* Updated Docs

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

* Reworked Implementation For Formatters

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

* Cleanup

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

* Added Test

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

* Fixed Implementation And Code Coverage

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

* Changed getFormatter Function

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

* Added Comments

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

---------

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

* Removed Unneeded Code

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

---------

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
(cherry picked from commit d38a6ec)
Yury-Fridlyand pushed a commit that referenced this pull request Mar 17, 2023
* Add The `TO_SECONDS` Function To The SQL Plugin (#232)

* Added Basic Tests

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

* Added IT Test

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

* Added Implementation

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

* Changed Integration Tests

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

* Added Test For Time Type

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

* Added Documentation

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

* Addressed PR Comments

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

* Fixed Docs and Implementation

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

* Fixed Checkstyle

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

* Changed DateTimeFormatter Priority

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

* Added More Formatters

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

* Updated Docs

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

* Reworked Implementation For Formatters

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

* Cleanup

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

* Added Test

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

* Fixed Implementation And Code Coverage

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

* Changed getFormatter Function

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

* Added Comments

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

---------

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

* Removed Unneeded Code

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

---------

Signed-off-by: GabeFernandez310 <Gabriel.Fernandez@improving.com>
(cherry picked from commit d38a6ec)
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.

6 participants