mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
parseDateTimeBestEffort support Unix Timestamp with Milliseconds
This commit is contained in:
parent
f18223f51e
commit
9004e98992
@ -151,7 +151,18 @@ ReturnType parseDateTimeBestEffortImpl(
|
|||||||
{
|
{
|
||||||
num_digits = readDigits(digits, sizeof(digits), in);
|
num_digits = readDigits(digits, sizeof(digits), in);
|
||||||
|
|
||||||
if (num_digits == 10 && !year && !has_time)
|
if (num_digits == 13 && !year && !has_time)
|
||||||
|
{
|
||||||
|
/// This is unix timestamp with millisecond.
|
||||||
|
readDecimalNumber<10>(res, digits);
|
||||||
|
if (fractional)
|
||||||
|
{
|
||||||
|
fractional->digits = 3;
|
||||||
|
readDecimalNumber<3>(fractional->value, digits + 10);
|
||||||
|
}
|
||||||
|
return ReturnType(true);
|
||||||
|
}
|
||||||
|
else if (num_digits == 10 && !year && !has_time)
|
||||||
{
|
{
|
||||||
/// This is unix timestamp.
|
/// This is unix timestamp.
|
||||||
readDecimalNumber<10>(res, digits);
|
readDecimalNumber<10>(res, digits);
|
||||||
|
@ -13,3 +13,7 @@ Formats
|
|||||||
2020-05-14 03:37:03.253
|
2020-05-14 03:37:03.253
|
||||||
2020-05-14 03:37:03.000
|
2020-05-14 03:37:03.000
|
||||||
2020-05-14 03:37:03.000
|
2020-05-14 03:37:03.000
|
||||||
|
Unix Timestamp with Milliseconds
|
||||||
|
2021-12-28 00:00:00.123
|
||||||
|
2021-12-28 00:00:00.1
|
||||||
|
2021-12-28 00:00:00.123000
|
||||||
|
@ -30,4 +30,9 @@ SELECT parseDateTime64BestEffort('2020-05-14T03:37:03.253184Z', 3, 'Europe/Minsk
|
|||||||
SELECT 'Formats';
|
SELECT 'Formats';
|
||||||
SELECT parseDateTime64BestEffort('2020-05-14T03:37:03.253184', 3, 'UTC');
|
SELECT parseDateTime64BestEffort('2020-05-14T03:37:03.253184', 3, 'UTC');
|
||||||
SELECT parseDateTime64BestEffort('2020-05-14T03:37:03', 3, 'UTC');
|
SELECT parseDateTime64BestEffort('2020-05-14T03:37:03', 3, 'UTC');
|
||||||
SELECT parseDateTime64BestEffort('2020-05-14 03:37:03', 3, 'UTC');
|
SELECT parseDateTime64BestEffort('2020-05-14 03:37:03', 3, 'UTC');
|
||||||
|
|
||||||
|
SELECT 'Unix Timestamp with Milliseconds'
|
||||||
|
SELECT parseDateTime64BestEffort('1640649600123', 3, 'UTC')
|
||||||
|
SELECT parseDateTime64BestEffort('1640649600123', 1, 'UTC')
|
||||||
|
SELECT parseDateTime64BestEffort('1640649600123', 6, 'UTC')
|
||||||
|
@ -13,6 +13,8 @@ parseDateTimeBestEffort
|
|||||||
2020-05-14 03:37:03.253 DateTime64(3, \'UTC\')
|
2020-05-14 03:37:03.253 DateTime64(3, \'UTC\')
|
||||||
2020-05-14 06:37:03.253 DateTime64(3, \'Europe/Minsk\')
|
2020-05-14 06:37:03.253 DateTime64(3, \'Europe/Minsk\')
|
||||||
2020-05-14 03:37:03.253 DateTime64(3, \'UTC\')
|
2020-05-14 03:37:03.253 DateTime64(3, \'UTC\')
|
||||||
|
2021-12-28 00:00:00.123 DateTime64(3, \'UTC\')
|
||||||
|
2021-12-28 00:00:00 DateTime(\'UTC\')
|
||||||
parseDateTimeBestEffortOrNull
|
parseDateTimeBestEffortOrNull
|
||||||
\N Nullable(DateTime64(3))
|
\N Nullable(DateTime64(3))
|
||||||
2020-05-14 03:37:03.000 Nullable(DateTime64(3, \'UTC\'))
|
2020-05-14 03:37:03.000 Nullable(DateTime64(3, \'UTC\'))
|
||||||
@ -25,6 +27,8 @@ parseDateTimeBestEffortOrNull
|
|||||||
2020-05-14 03:37:03.253 Nullable(DateTime64(3, \'UTC\'))
|
2020-05-14 03:37:03.253 Nullable(DateTime64(3, \'UTC\'))
|
||||||
2020-05-14 06:37:03.253 Nullable(DateTime64(3, \'Europe/Minsk\'))
|
2020-05-14 06:37:03.253 Nullable(DateTime64(3, \'Europe/Minsk\'))
|
||||||
2020-05-14 03:37:03.253 Nullable(DateTime64(3, \'UTC\'))
|
2020-05-14 03:37:03.253 Nullable(DateTime64(3, \'UTC\'))
|
||||||
|
2021-12-28 00:00:00.123 Nullable(DateTime64(3, \'UTC\'))
|
||||||
|
2021-12-28 00:00:00 Nullable(DateTime(\'UTC\'))
|
||||||
parseDateTimeBestEffortOrZero
|
parseDateTimeBestEffortOrZero
|
||||||
1970-01-01 00:00:00.000 DateTime64(3, \'UTC\')
|
1970-01-01 00:00:00.000 DateTime64(3, \'UTC\')
|
||||||
2020-05-14 03:37:03.000 DateTime64(3, \'UTC\')
|
2020-05-14 03:37:03.000 DateTime64(3, \'UTC\')
|
||||||
@ -37,6 +41,8 @@ parseDateTimeBestEffortOrZero
|
|||||||
2020-05-14 03:37:03.253 DateTime64(3, \'UTC\')
|
2020-05-14 03:37:03.253 DateTime64(3, \'UTC\')
|
||||||
2020-05-14 06:37:03.253 DateTime64(3, \'Europe/Minsk\')
|
2020-05-14 06:37:03.253 DateTime64(3, \'Europe/Minsk\')
|
||||||
2020-05-14 03:37:03.253 DateTime64(3, \'UTC\')
|
2020-05-14 03:37:03.253 DateTime64(3, \'UTC\')
|
||||||
|
2021-12-28 00:00:00.123 DateTime64(3, \'UTC\')
|
||||||
|
2021-12-28 00:00:00 DateTime(\'UTC\')
|
||||||
parseDateTime32BestEffort
|
parseDateTime32BestEffort
|
||||||
2020-05-14 03:37:03 DateTime(\'UTC\')
|
2020-05-14 03:37:03 DateTime(\'UTC\')
|
||||||
2020-05-14 03:37:03 DateTime(\'UTC\')
|
2020-05-14 03:37:03 DateTime(\'UTC\')
|
||||||
@ -48,6 +54,7 @@ parseDateTime32BestEffort
|
|||||||
2020-05-14 03:37:03 DateTime(\'UTC\')
|
2020-05-14 03:37:03 DateTime(\'UTC\')
|
||||||
2020-05-14 06:37:03 DateTime(\'Europe/Minsk\')
|
2020-05-14 06:37:03 DateTime(\'Europe/Minsk\')
|
||||||
2020-05-14 03:37:03 DateTime(\'UTC\')
|
2020-05-14 03:37:03 DateTime(\'UTC\')
|
||||||
|
2021-12-28 00:00:00 DateTime(\'UTC\')
|
||||||
parseDateTime32BestEffortOrNull
|
parseDateTime32BestEffortOrNull
|
||||||
\N Nullable(DateTime)
|
\N Nullable(DateTime)
|
||||||
2020-05-14 03:37:03 Nullable(DateTime(\'UTC\'))
|
2020-05-14 03:37:03 Nullable(DateTime(\'UTC\'))
|
||||||
@ -60,6 +67,7 @@ parseDateTime32BestEffortOrNull
|
|||||||
2020-05-14 03:37:03 Nullable(DateTime(\'UTC\'))
|
2020-05-14 03:37:03 Nullable(DateTime(\'UTC\'))
|
||||||
2020-05-14 06:37:03 Nullable(DateTime(\'Europe/Minsk\'))
|
2020-05-14 06:37:03 Nullable(DateTime(\'Europe/Minsk\'))
|
||||||
2020-05-14 03:37:03 Nullable(DateTime(\'UTC\'))
|
2020-05-14 03:37:03 Nullable(DateTime(\'UTC\'))
|
||||||
|
2021-12-28 00:00:00 Nullable(DateTime(\'UTC\'))
|
||||||
parseDateTime32BestEffortOrZero
|
parseDateTime32BestEffortOrZero
|
||||||
1970-01-01 00:00:00 DateTime(\'UTC\')
|
1970-01-01 00:00:00 DateTime(\'UTC\')
|
||||||
2020-05-14 03:37:03 DateTime(\'UTC\')
|
2020-05-14 03:37:03 DateTime(\'UTC\')
|
||||||
@ -72,3 +80,4 @@ parseDateTime32BestEffortOrZero
|
|||||||
2020-05-14 03:37:03 DateTime(\'UTC\')
|
2020-05-14 03:37:03 DateTime(\'UTC\')
|
||||||
2020-05-14 06:37:03 DateTime(\'Europe/Minsk\')
|
2020-05-14 06:37:03 DateTime(\'Europe/Minsk\')
|
||||||
2020-05-14 03:37:03 DateTime(\'UTC\')
|
2020-05-14 03:37:03 DateTime(\'UTC\')
|
||||||
|
2021-12-28 00:00:00 DateTime(\'UTC\')
|
@ -24,6 +24,8 @@ SELECT parseDateTimeBestEffort('2020-05-14T03:37:03.253184', 3, 'UTC') AS a, toT
|
|||||||
SELECT parseDateTimeBestEffort('2020-05-14T03:37:03.253184Z', 3, 'UTC') AS a, toTypeName(a);
|
SELECT parseDateTimeBestEffort('2020-05-14T03:37:03.253184Z', 3, 'UTC') AS a, toTypeName(a);
|
||||||
SELECT parseDateTimeBestEffort('2020-05-14T03:37:03.253184Z', 3, 'Europe/Minsk') AS a, toTypeName(a);
|
SELECT parseDateTimeBestEffort('2020-05-14T03:37:03.253184Z', 3, 'Europe/Minsk') AS a, toTypeName(a);
|
||||||
SELECT parseDateTimeBestEffort(materialize('2020-05-14T03:37:03.253184Z'), 3, 'UTC') AS a, toTypeName(a);
|
SELECT parseDateTimeBestEffort(materialize('2020-05-14T03:37:03.253184Z'), 3, 'UTC') AS a, toTypeName(a);
|
||||||
|
SELECT parseDateTimeBestEffort('1640649600123', 3, 'UTC') AS a, toTypeName(a);
|
||||||
|
SELECT parseDateTimeBestEffort('1640649600123', 'UTC') AS a, toTypeName(a);
|
||||||
|
|
||||||
SELECT 'parseDateTimeBestEffortOrNull';
|
SELECT 'parseDateTimeBestEffortOrNull';
|
||||||
SELECT parseDateTimeBestEffortOrNull('<Empty>', 3) AS a, toTypeName(a);
|
SELECT parseDateTimeBestEffortOrNull('<Empty>', 3) AS a, toTypeName(a);
|
||||||
@ -37,6 +39,8 @@ SELECT parseDateTimeBestEffortOrNull('2020-05-14T03:37:03.253184', 3, 'UTC') AS
|
|||||||
SELECT parseDateTimeBestEffortOrNull('2020-05-14T03:37:03.253184Z', 3, 'UTC') AS a, toTypeName(a);
|
SELECT parseDateTimeBestEffortOrNull('2020-05-14T03:37:03.253184Z', 3, 'UTC') AS a, toTypeName(a);
|
||||||
SELECT parseDateTimeBestEffortOrNull('2020-05-14T03:37:03.253184Z', 3, 'Europe/Minsk') AS a, toTypeName(a);
|
SELECT parseDateTimeBestEffortOrNull('2020-05-14T03:37:03.253184Z', 3, 'Europe/Minsk') AS a, toTypeName(a);
|
||||||
SELECT parseDateTimeBestEffortOrNull(materialize('2020-05-14T03:37:03.253184Z'), 3, 'UTC') AS a, toTypeName(a);
|
SELECT parseDateTimeBestEffortOrNull(materialize('2020-05-14T03:37:03.253184Z'), 3, 'UTC') AS a, toTypeName(a);
|
||||||
|
SELECT parseDateTimeBestEffortOrNull('1640649600123', 3, 'UTC') AS a, toTypeName(a);
|
||||||
|
SELECT parseDateTimeBestEffortOrNull('1640649600123', 'UTC') AS a, toTypeName(a);
|
||||||
|
|
||||||
SELECT 'parseDateTimeBestEffortOrZero';
|
SELECT 'parseDateTimeBestEffortOrZero';
|
||||||
SELECT parseDateTimeBestEffortOrZero('<Empty>', 3, 'UTC') AS a, toTypeName(a);
|
SELECT parseDateTimeBestEffortOrZero('<Empty>', 3, 'UTC') AS a, toTypeName(a);
|
||||||
@ -50,6 +54,8 @@ SELECT parseDateTimeBestEffortOrZero('2020-05-14T03:37:03.253184', 3, 'UTC') AS
|
|||||||
SELECT parseDateTimeBestEffortOrZero('2020-05-14T03:37:03.253184Z', 3, 'UTC') AS a, toTypeName(a);
|
SELECT parseDateTimeBestEffortOrZero('2020-05-14T03:37:03.253184Z', 3, 'UTC') AS a, toTypeName(a);
|
||||||
SELECT parseDateTimeBestEffortOrZero('2020-05-14T03:37:03.253184Z', 3, 'Europe/Minsk') AS a, toTypeName(a);
|
SELECT parseDateTimeBestEffortOrZero('2020-05-14T03:37:03.253184Z', 3, 'Europe/Minsk') AS a, toTypeName(a);
|
||||||
SELECT parseDateTimeBestEffortOrZero(materialize('2020-05-14T03:37:03.253184Z'), 3, 'UTC') AS a, toTypeName(a);
|
SELECT parseDateTimeBestEffortOrZero(materialize('2020-05-14T03:37:03.253184Z'), 3, 'UTC') AS a, toTypeName(a);
|
||||||
|
SELECT parseDateTimeBestEffortOrZero('1640649600123', 3, 'UTC') AS a, toTypeName(a);
|
||||||
|
SELECT parseDateTimeBestEffortOrZero('1640649600123', 'UTC') AS a, toTypeName(a);
|
||||||
|
|
||||||
SELECT 'parseDateTime32BestEffort';
|
SELECT 'parseDateTime32BestEffort';
|
||||||
SELECT parseDateTime32BestEffort('<Empty>') AS a, toTypeName(a); -- {serverError 41}
|
SELECT parseDateTime32BestEffort('<Empty>') AS a, toTypeName(a); -- {serverError 41}
|
||||||
@ -63,6 +69,7 @@ SELECT parseDateTime32BestEffort('2020-05-14T03:37:03.253184', 'UTC') AS a, toTy
|
|||||||
SELECT parseDateTime32BestEffort('2020-05-14T03:37:03.253184Z', 'UTC') AS a, toTypeName(a);
|
SELECT parseDateTime32BestEffort('2020-05-14T03:37:03.253184Z', 'UTC') AS a, toTypeName(a);
|
||||||
SELECT parseDateTime32BestEffort('2020-05-14T03:37:03.253184Z', 'Europe/Minsk') AS a, toTypeName(a);
|
SELECT parseDateTime32BestEffort('2020-05-14T03:37:03.253184Z', 'Europe/Minsk') AS a, toTypeName(a);
|
||||||
SELECT parseDateTime32BestEffort(materialize('2020-05-14T03:37:03.253184Z'), 'UTC') AS a, toTypeName(a);
|
SELECT parseDateTime32BestEffort(materialize('2020-05-14T03:37:03.253184Z'), 'UTC') AS a, toTypeName(a);
|
||||||
|
SELECT parseDateTime32BestEffort('1640649600123', 'UTC') AS a, toTypeName(a);
|
||||||
|
|
||||||
SELECT 'parseDateTime32BestEffortOrNull';
|
SELECT 'parseDateTime32BestEffortOrNull';
|
||||||
SELECT parseDateTime32BestEffortOrNull('<Empty>') AS a, toTypeName(a);
|
SELECT parseDateTime32BestEffortOrNull('<Empty>') AS a, toTypeName(a);
|
||||||
@ -76,6 +83,7 @@ SELECT parseDateTime32BestEffortOrNull('2020-05-14T03:37:03.253184', 'UTC') AS a
|
|||||||
SELECT parseDateTime32BestEffortOrNull('2020-05-14T03:37:03.253184Z', 'UTC') AS a, toTypeName(a);
|
SELECT parseDateTime32BestEffortOrNull('2020-05-14T03:37:03.253184Z', 'UTC') AS a, toTypeName(a);
|
||||||
SELECT parseDateTime32BestEffortOrNull('2020-05-14T03:37:03.253184Z', 'Europe/Minsk') AS a, toTypeName(a);
|
SELECT parseDateTime32BestEffortOrNull('2020-05-14T03:37:03.253184Z', 'Europe/Minsk') AS a, toTypeName(a);
|
||||||
SELECT parseDateTime32BestEffortOrNull(materialize('2020-05-14T03:37:03.253184Z'), 'UTC') AS a, toTypeName(a);
|
SELECT parseDateTime32BestEffortOrNull(materialize('2020-05-14T03:37:03.253184Z'), 'UTC') AS a, toTypeName(a);
|
||||||
|
SELECT parseDateTime32BestEffortOrNull('1640649600123', 'UTC') AS a, toTypeName(a);
|
||||||
|
|
||||||
SELECT 'parseDateTime32BestEffortOrZero';
|
SELECT 'parseDateTime32BestEffortOrZero';
|
||||||
SELECT parseDateTime32BestEffortOrZero('<Empty>', 'UTC') AS a, toTypeName(a);
|
SELECT parseDateTime32BestEffortOrZero('<Empty>', 'UTC') AS a, toTypeName(a);
|
||||||
@ -89,6 +97,6 @@ SELECT parseDateTime32BestEffortOrZero('2020-05-14T03:37:03.253184', 'UTC') AS a
|
|||||||
SELECT parseDateTime32BestEffortOrZero('2020-05-14T03:37:03.253184Z', 'UTC') AS a, toTypeName(a);
|
SELECT parseDateTime32BestEffortOrZero('2020-05-14T03:37:03.253184Z', 'UTC') AS a, toTypeName(a);
|
||||||
SELECT parseDateTime32BestEffortOrZero('2020-05-14T03:37:03.253184Z', 'Europe/Minsk') AS a, toTypeName(a);
|
SELECT parseDateTime32BestEffortOrZero('2020-05-14T03:37:03.253184Z', 'Europe/Minsk') AS a, toTypeName(a);
|
||||||
SELECT parseDateTime32BestEffortOrZero(materialize('2020-05-14T03:37:03.253184Z'), 'UTC') AS a, toTypeName(a);
|
SELECT parseDateTime32BestEffortOrZero(materialize('2020-05-14T03:37:03.253184Z'), 'UTC') AS a, toTypeName(a);
|
||||||
|
SELECT parseDateTime32BestEffortOrZero('1640649600123', 'UTC') AS a, toTypeName(a);
|
||||||
|
|
||||||
DROP TABLE IF EXISTS test;
|
DROP TABLE IF EXISTS test;
|
||||||
|
Loading…
Reference in New Issue
Block a user