Merge pull request #32240 from benbiti/master

Fix unix timestamp Millisecond convert to DateTime64, fractional part calc reversed
This commit is contained in:
Nikolay Degterinsky 2021-12-23 12:11:53 +03:00 committed by GitHub
commit 826f7cb0f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 9 deletions

View File

@ -899,13 +899,8 @@ inline ReturnType readDateTimeTextImpl(DateTime64 & datetime64, UInt32 scale, Re
{
/// Unix timestamp with subsecond precision, already scaled to integer.
/// For disambiguation we support only time since 2001-09-09 01:46:40 UTC and less than 30 000 years in future.
for (size_t i = 0; i < scale; ++i)
{
components.fractional *= 10;
components.fractional += components.whole % 10;
components.whole /= 10;
}
components.fractional = components.whole % common::exp10_i32(scale);
components.whole = components.whole / common::exp10_i32(scale);
}
datetime64 = DecimalUtils::decimalFromComponents<DateTime64>(components, scale);

View File

@ -0,0 +1,2 @@
2283-11-11 23:48:05.4775806
2283-11-11 23:52:48.54775806

View File

@ -1,2 +1,2 @@
SELECT toDateTime('9223372036854775806', 7); -- { serverError 407 }
SELECT toDateTime('9223372036854775806', 8); -- { serverError 407 }
SELECT toDateTime('9223372036854775806', 7);
SELECT toDateTime('9223372036854775806', 8);