diff --git a/programs/odbc-bridge/ODBCBlockInputStream.cpp b/programs/odbc-bridge/ODBCBlockInputStream.cpp index 3cf10171a94..45ab4e51d8f 100644 --- a/programs/odbc-bridge/ODBCBlockInputStream.cpp +++ b/programs/odbc-bridge/ODBCBlockInputStream.cpp @@ -149,8 +149,6 @@ void ODBCSource::insertValue( DateTime64 time = 0; const auto * datetime_type = assert_cast(data_type.get()); readDateTime64Text(time, datetime_type->getScale(), in, datetime_type->getTimeZone()); - if (time < 0) - time = 0; assert_cast(column).insertValue(time); break; } diff --git a/src/Core/PostgreSQL/insertPostgreSQLValue.cpp b/src/Core/PostgreSQL/insertPostgreSQLValue.cpp index f4d47049554..b51bbafef54 100644 --- a/src/Core/PostgreSQL/insertPostgreSQLValue.cpp +++ b/src/Core/PostgreSQL/insertPostgreSQLValue.cpp @@ -108,8 +108,6 @@ void insertPostgreSQLValue( ReadBufferFromString in(value); DateTime64 time = 0; readDateTime64Text(time, 6, in, assert_cast(data_type.get())->getTimeZone()); - if (time < 0) - time = 0; assert_cast(column).insertValue(time); break; } diff --git a/tests/integration/test_storage_postgresql/test.py b/tests/integration/test_storage_postgresql/test.py index 87337a6b459..55be61e052b 100644 --- a/tests/integration/test_storage_postgresql/test.py +++ b/tests/integration/test_storage_postgresql/test.py @@ -447,6 +447,16 @@ def test_where_false(started_cluster): cursor.execute("DROP TABLE test") +def test_datetime64(started_cluster): + cursor = started_cluster.postgres_conn.cursor() + cursor.execute("drop table if exists test") + cursor.execute("create table test (ts timestamp)") + cursor.execute("insert into test select '1960-01-01 20:00:00';") + + result = node1.query("select * from postgresql(postgres1, table='test')") + assert(result.strip() == '1960-01-01 20:00:00.000000') + + if __name__ == '__main__': cluster.start() input("Cluster created, press any key to destroy...")