diff --git a/src/IO/ReadHelpers.h b/src/IO/ReadHelpers.h index 369237f329d..ab9e1a250d0 100644 --- a/src/IO/ReadHelpers.h +++ b/src/IO/ReadHelpers.h @@ -773,7 +773,8 @@ inline ReturnType readDateTimeTextImpl(DateTime64 & datetime64, UInt32 scale, Re while (!buf.eof() && isNumericASCII(*buf.position())) ++buf.position(); } - else if (scale && (whole >= 1000000000LL * scale)) + //9908870400 is time_t value for 2084-01-01 UTC (a bit over the last year supported by DateTime64) + else if (scale && scale < 18 && (whole >= 9908870400LL * static_cast(intExp10(scale)))) { /// 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. diff --git a/tests/queries/0_stateless/018002_formatDateTime_DateTime64_century.reference b/tests/queries/0_stateless/018002_formatDateTime_DateTime64_century.reference index 68e793c55a2..75c114cdd74 100644 --- a/tests/queries/0_stateless/018002_formatDateTime_DateTime64_century.reference +++ b/tests/queries/0_stateless/018002_formatDateTime_DateTime64_century.reference @@ -23,5 +23,5 @@ SELECT formatDateTime(toDateTime64('2019-09-16 19:20:12', 0, 'Europe/Moscow'), ' 20 SELECT formatDateTime(toDateTime64('2105-12-12 12:12:12', 6, 'Europe/Moscow'), '%C'); 21 -SELECT formatDateTime(toDateTime64('2205-12-12 12:12:12', 6, 'Europe/Moscow'), '%C'); -19 +SELECT formatDateTime(toDateTime64('2205-01-12 12:12:12', 6, 'Europe/Moscow'), '%C'); +22 diff --git a/tests/queries/0_stateless/018002_formatDateTime_DateTime64_century.sql b/tests/queries/0_stateless/018002_formatDateTime_DateTime64_century.sql index 2d432c93163..e368f45cbda 100644 --- a/tests/queries/0_stateless/018002_formatDateTime_DateTime64_century.sql +++ b/tests/queries/0_stateless/018002_formatDateTime_DateTime64_century.sql @@ -13,4 +13,4 @@ SELECT formatDateTime(toDateTime64('1969-12-12 12:12:12', 6, 'Europe/Moscow'), ' SELECT formatDateTime(toDateTime64('1989-12-12 12:12:12', 6, 'Europe/Moscow'), '%C'); SELECT formatDateTime(toDateTime64('2019-09-16 19:20:12', 0, 'Europe/Moscow'), '%C'); SELECT formatDateTime(toDateTime64('2105-12-12 12:12:12', 6, 'Europe/Moscow'), '%C'); -SELECT formatDateTime(toDateTime64('2205-12-12 12:12:12', 6, 'Europe/Moscow'), '%C'); \ No newline at end of file +SELECT formatDateTime(toDateTime64('2205-01-12 12:12:12', 6, 'Europe/Moscow'), '%C'); \ No newline at end of file diff --git a/tests/queries/0_stateless/018002_toDateTime64_large_values.reference b/tests/queries/0_stateless/018002_toDateTime64_large_values.reference new file mode 100644 index 00000000000..c44c61ab93a --- /dev/null +++ b/tests/queries/0_stateless/018002_toDateTime64_large_values.reference @@ -0,0 +1,10 @@ +-- { echo } + +SELECT toDateTime64('2205-12-12 12:12:12', 0, 'UTC'); +2205-12-12 12:12:12 +SELECT toDateTime64('2205-12-12 12:12:12', 0, 'Europe/Moscow'); +2205-12-12 12:12:12 +SELECT toDateTime64('2205-12-12 12:12:12', 6, 'Europe/Moscow'); +2205-12-12 12:12:12.000000 +SELECT toDateTime64('2205-12-12 12:12:12', 6, 'Europe/Moscow'); +2205-12-12 12:12:12.000000 diff --git a/tests/queries/0_stateless/018002_toDateTime64_large_values.sql b/tests/queries/0_stateless/018002_toDateTime64_large_values.sql new file mode 100644 index 00000000000..299111f43bc --- /dev/null +++ b/tests/queries/0_stateless/018002_toDateTime64_large_values.sql @@ -0,0 +1,7 @@ +-- { echo } + +SELECT toDateTime64('2205-12-12 12:12:12', 0, 'UTC'); +SELECT toDateTime64('2205-12-12 12:12:12', 0, 'Europe/Moscow'); + +SELECT toDateTime64('2205-12-12 12:12:12', 6, 'Europe/Moscow'); +SELECT toDateTime64('2205-12-12 12:12:12', 6, 'Europe/Moscow'); \ No newline at end of file