mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Merge pull request #34208 from ClickHouse/parse-date-time-best-effort-more-cases
More cases for `parseDateTimeBestEffort`
This commit is contained in:
commit
2b1d1a9a6f
@ -194,7 +194,7 @@ ReturnType parseDateTimeBestEffortImpl(
|
||||
}
|
||||
else if (num_digits == 6)
|
||||
{
|
||||
/// This is YYYYMM
|
||||
/// This is YYYYMM or hhmmss
|
||||
if (!year && !month)
|
||||
{
|
||||
readDecimalNumber<4>(year, digits);
|
||||
@ -435,12 +435,23 @@ ReturnType parseDateTimeBestEffortImpl(
|
||||
else if (c == '+' || c == '-')
|
||||
{
|
||||
++in.position();
|
||||
num_digits = readDigits(digits, sizeof(digits), in);
|
||||
|
||||
if (num_digits == 6 && !has_time && year && month && day_of_month)
|
||||
{
|
||||
/// It looks like hhmmss
|
||||
readDecimalNumber<2>(hour, digits);
|
||||
readDecimalNumber<2>(minute, digits + 2);
|
||||
readDecimalNumber<2>(second, digits + 4);
|
||||
has_time = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
/// It looks like time zone offset
|
||||
has_time_zone_offset = true;
|
||||
if (c == '-')
|
||||
time_zone_offset_negative = true;
|
||||
|
||||
num_digits = readDigits(digits, sizeof(digits), in);
|
||||
|
||||
if (num_digits == 4)
|
||||
{
|
||||
readDecimalNumber<2>(time_zone_offset_hour, digits);
|
||||
@ -478,6 +489,7 @@ ReturnType parseDateTimeBestEffortImpl(
|
||||
return on_error("Cannot read DateTime: unexpected number of decimal digits for time zone offset in minutes: " + toString(num_digits), ErrorCodes::CANNOT_PARSE_DATETIME);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
char alpha[3];
|
||||
|
@ -0,0 +1,10 @@
|
||||
2022-01-01 01:02:03
|
||||
2022-01-01 01:02:03
|
||||
2022-01-01 01:02:03
|
||||
2022-01-01 01:02:03
|
||||
2022-01-01 01:02:00
|
||||
2022-01-01 01:02:00
|
||||
2021-12-31 22:58:00
|
||||
2022-01-01 02:02:03
|
||||
2022-01-01 00:02:03
|
||||
2022-01-01 02:02:03
|
@ -0,0 +1,10 @@
|
||||
SELECT parseDateTimeBestEffort('20220101-010203', 'UTC');
|
||||
SELECT parseDateTimeBestEffort('20220101+010203', 'UTC');
|
||||
SELECT parseDateTimeBestEffort('20220101 010203', 'UTC');
|
||||
SELECT parseDateTimeBestEffort('20220101T010203', 'UTC');
|
||||
SELECT parseDateTimeBestEffort('20220101T01:02', 'UTC');
|
||||
SELECT parseDateTimeBestEffort('20220101-0102', 'UTC');
|
||||
SELECT parseDateTimeBestEffort('20220101+0102', 'UTC');
|
||||
SELECT parseDateTimeBestEffort('20220101-010203-01', 'UTC');
|
||||
SELECT parseDateTimeBestEffort('20220101-010203+0100', 'UTC');
|
||||
SELECT parseDateTimeBestEffort('20220101-010203-01:00', 'UTC');
|
Loading…
Reference in New Issue
Block a user