function toStartOfSecond(DateTime64) -> DateTime64#10722
Merged
alexey-milovidov merged 1 commit intoClickHouse:masterfrom May 11, 2020
Enmk:DateTime64_fixes
Merged
function toStartOfSecond(DateTime64) -> DateTime64#10722alexey-milovidov merged 1 commit intoClickHouse:masterfrom Enmk:DateTime64_fixes
alexey-milovidov merged 1 commit intoClickHouse:masterfrom
Enmk:DateTime64_fixes
Conversation
src/Core/DecimalFunctions.h
Outdated
Member
There was a problem hiding this comment.
Maybe result = -result will look better?
(no difference in the behaviour indeed)
src/Functions/DateTimeTransforms.h
Outdated
Member
There was a problem hiding this comment.
It does not look correct for negative values (that will be introduced in another PR).
Example:
value is -0.3
fractional part that you calculate is 0.3
value - fractional = -0.6
But if I understand correctly, you want to round down to -1.0 (towards minus infinity).
src/DataTypes/DataTypeDateTime64.h
Outdated
Member
There was a problem hiding this comment.
It looks old-fashioned, maybe it's possible to use std::enable_if_t?
alexey-milovidov
requested changes
May 8, 2020
Member
alexey-milovidov
left a comment
There was a problem hiding this comment.
Small questions remain.
This funtion nullifies sub-second part of DateTime64 value.
alexey-milovidov
approved these changes
May 11, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This function nullifies the sub-second part of DateTime64 value.
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
New function function toStartOfSecond(DateTime64) -> DateTime64 that nullifies sub-second part of DateTime64 value.
Detailed description / Documentation draft:
toStartOfSecond(
value,timezone)Returns new DateTime64 with nullified sub-second part and (optionally) different timezone.
value-DateTime64timezone-String, optional timezone for the return value.return- aDateTime64of the same precision (and same timezone unless specified explicitly) asvalue, but with sub-second part nullified.Example:
...