Skip to content

datetime2timestamp and timestamp2datetime #4526

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

Merged
merged 1 commit into from
Aug 16, 2022

Conversation

caton-hpg
Copy link
Contributor

What type of PR is this?

  • bug
  • feature
  • enhancement

What problem(s) does this PR solve?

Issue(s) number: #4418

Description:

timestamp and datetime can be convert each other.

(root@nebula) [(none)]> return datetime(timestamp())
+----------------------------+
| datetime(timestamp())      |
+----------------------------+
| 2022-08-16T03:32:27.000000 |
+----------------------------+
Got 1 rows (time spent 1842/2836 us)

(root@nebula) [(none)]> return datetime(timestamp(0))
+----------------------------+
| datetime(timestamp(0))     |
+----------------------------+
| 1970-01-01T00:00:00.000000 |
+----------------------------+
Got 1 rows (time spent 1173/1822 us)

Tue, 16 Aug 2022 11:32:37 CST

(root@nebula) [(none)]> return timestamp(datetime())
+-----------------------+
| timestamp(datetime()) |
+-----------------------+
| 1660620772            |
+-----------------------+
Got 1 rows (time spent 1160/1962 us)

(root@nebula) [(none)]> return timestamp(datetime("2022-08-16"))
+-----------------------------------+
| timestamp(datetime("2022-08-16")) |
+-----------------------------------+
| 1660608000                        |
+-----------------------------------+
Got 1 rows (time spent 1292/1996 us)

How do you solve it?

modified: src/common/function/FunctionManager.cpp
modified: src/common/function/test/FunctionManagerTest.cpp
modified: src/common/time/TimeUtils.cpp

fixed datetime and timestadamp function.

Special notes for your reviewer, ex. impact of this fix, design document, etc:

Checklist:

Tests:

  • Unit test(positive and negative cases)
  • Function test
  • Performance test
  • N/A

Affects:

  • Documentation affected (Please add the label if documentation needs to be modified.)
  • Incompatibility (If it breaks the compatibility, please describe it and add the label.)
  • If it's needed to cherry-pick (If cherry-pick to some branches is required, please label the destination version(s).)
  • Performance impacted: Consumes more CPU/Memory

Release notes:

Please confirm whether to be reflected in release notes and how to describe:

Sorry, something went wrong.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@Sophie-Xie Sophie-Xie added the ready-for-testing PR: ready for the CI test label Aug 16, 2022
@Sophie-Xie Sophie-Xie merged commit 0f75120 into vesoft-inc:master Aug 16, 2022
@Shylock-Hg Shylock-Hg added the doc affected PR: improvements or additions to documentation label Aug 16, 2022
@Sophie-Xie Sophie-Xie requested a review from abby-cyber August 17, 2022 12:11
@abby-cyber abby-cyber added doc done PR:the doc for this PR is done. and removed doc affected PR: improvements or additions to documentation labels Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc done PR:the doc for this PR is done. ready-for-testing PR: ready for the CI test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants