From 8c454ae15b18de8d36e83487246b36b144d629e2 Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Wed, 7 Dec 2022 14:02:43 -0500 Subject: [PATCH 1/2] Add tests for coercion of timestamps to strings --- .../sqllogictests/test_files/timestamps.slt | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 datafusion/core/tests/sqllogictests/test_files/timestamps.slt diff --git a/datafusion/core/tests/sqllogictests/test_files/timestamps.slt b/datafusion/core/tests/sqllogictests/test_files/timestamps.slt new file mode 100644 index 0000000000000..5bd3b340ab620 --- /dev/null +++ b/datafusion/core/tests/sqllogictests/test_files/timestamps.slt @@ -0,0 +1,66 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +########## +## DDL Tests +########## + +statement ok +create table foo (val int, ts timestamp) as values (1, '2000-01-01T00:00:00'::timestamp), (2, '2000-02-01T00:00:00'::timestamp), (3, '2000-03-01T00:00:00'::timestamp); + +query C rowsort +select * from foo; +---- +1 2000-01-01T00:00:00.000000000 +2 2000-02-01T00:00:00.000000000 +3 2000-03-01T00:00:00.000000000 + +# Test that we can compare a timestamp to a casted string +query C rowsort +select * from foo where ts > '2000-01-01T00:00:00'::timestamp; +---- +2 2000-02-01T00:00:00.000000000 +3 2000-03-01T00:00:00.000000000 + +# Test that we can compare a timestamp to a string and it will be coerced +query C rowsort +select * from foo where ts > '2000-01-01T00:00:00'; +---- +2 2000-02-01T00:00:00.000000000 +3 2000-03-01T00:00:00.000000000 + +query C rowsort +select * from foo where ts < '2000-02-01T00:00:00'; +---- +1 2000-01-01T00:00:00.000000000 + +query C rowsort +select * from foo where ts <= '2000-02-01T00:00:00'; +---- +1 2000-01-01T00:00:00.000000000 +2 2000-02-01T00:00:00.000000000 + +query C rowsort +select * from foo where ts = '2000-02-01T00:00:00'; +---- +2 2000-02-01T00:00:00.000000000 + +query C rowsort +select * from foo where ts != '2000-02-01T00:00:00'; +---- +1 2000-01-01T00:00:00.000000000 +3 2000-03-01T00:00:00.000000000 From 01698fbd39328a833e2cc18e6eaf205ee2af5e52 Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Thu, 8 Dec 2022 07:16:29 -0500 Subject: [PATCH 2/2] Update datafusion/core/tests/sqllogictests/test_files/timestamps.slt --- datafusion/core/tests/sqllogictests/test_files/timestamps.slt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datafusion/core/tests/sqllogictests/test_files/timestamps.slt b/datafusion/core/tests/sqllogictests/test_files/timestamps.slt index 5bd3b340ab620..f4d627df4523d 100644 --- a/datafusion/core/tests/sqllogictests/test_files/timestamps.slt +++ b/datafusion/core/tests/sqllogictests/test_files/timestamps.slt @@ -16,7 +16,7 @@ # under the License. ########## -## DDL Tests +## Timestamp Handling Tests ########## statement ok