'T' is added as delimiter, tests added

This commit is contained in:
Yakov Olkhovskiy 2022-04-05 19:50:16 -04:00
parent 79c75d8a71
commit ea9ce3ea18
3 changed files with 13 additions and 6 deletions

View File

@ -867,7 +867,8 @@ inline ReturnType readDateTimeTextImpl(time_t & datetime, ReadBuffer & buf, cons
UInt8 minute = 0;
UInt8 second = 0;
///simply determine whether it is YYYY-MM-DD hh:mm:ss or YYYY-MM-DD by the content of the tenth character in an optimistic scenario
if (s[10] == ' ')
bool dt_long = (s[10] == ' ' || s[10] == 'T');
if (dt_long)
{
hour = (s[11] - '0') * 10 + (s[12] - '0');
minute = (s[14] - '0') * 10 + (s[15] - '0');
@ -879,7 +880,7 @@ inline ReturnType readDateTimeTextImpl(time_t & datetime, ReadBuffer & buf, cons
else
datetime = date_lut.makeDateTime(year, month, day, hour, minute, second);
if (s[10] == ' ')
if (dt_long)
buf.position() += DateTimeStringInputSize;
else
buf.position() += DateStringInputSize;

View File

@ -1,3 +1,5 @@
2022-03-31 00:00:00 1
2022-04-01 17:10:24 2
2022-03-31 10:18:56 3
2022-03-31T04:00:00Z 1
2022-04-01T09:10:24Z 2
2022-03-31T14:18:56Z 3
2022-03-31T14:18:56Z 4
2022-04-01T09:10:24Z 5

View File

@ -1,6 +1,10 @@
SET date_time_output_format='iso';
drop table if exists t;
CREATE TABLE t (a DateTime, b String, c String, d String, e Int32) ENGINE = Memory;
INSERT INTO t(a, b, c, d ,e) VALUES ('2022-03-31','','','',1);
INSERT INTO t(a, b, c, d ,e) VALUES (1648804224,'','','',2);
INSERT INTO t(a, b, c, d ,e) VALUES ('2022-03-31 10:18:56','','','',3);
select a, e from t;
INSERT INTO t(a, b, c, d ,e) VALUES ('2022-03-31T10:18:56','','','',4);
INSERT INTO t(a, b, c, d ,e) VALUES ('1648804224','','','',5);
select a, e from t order by e;
drop table if exists t;