Skip to content

Commit c153c13

Browse files
authored
Minor: Add tests for date interval predicate handling (#4569)
1 parent 2457ce4 commit c153c13

2 files changed

Lines changed: 88 additions & 0 deletions

File tree

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
##########
19+
## Date/Time Handling Tests
20+
##########
21+
22+
# Reproducer for https://github.com/apache/arrow-datafusion/issues/3944
23+
statement ok
24+
CREATE TABLE test(
25+
i_item_desc VARCHAR,
26+
d1_date DATE,
27+
d2_date DATE,
28+
d3_date DATE
29+
) as VALUES
30+
('a','2022-12-12','2022-12-12','2022-12-12'),
31+
('b','2022-12-12','2022-12-11','2022-12-12'),
32+
('c','2022-12-12','2022-12-10','2022-12-12'),
33+
('d','2022-12-12','2022-12-9','2022-12-12'),
34+
('e','2022-12-12','2022-12-8','2022-12-12'),
35+
('f','2022-12-12','2022-12-7','2022-12-12'),
36+
('g','2022-12-12','2022-12-6','2022-12-12'),
37+
('h','2022-12-12','2022-12-5','2022-12-12')
38+
;
39+
40+
41+
query C rowsort
42+
select i_item_desc
43+
from test
44+
where d3_date > d2_date + INTERVAL '1 days';
45+
----
46+
c
47+
d
48+
e
49+
f
50+
g
51+
h
52+
53+
query C rowsort
54+
select i_item_desc
55+
from test
56+
where d3_date > d2_date + INTERVAL '5 days';
57+
----
58+
g
59+
h
60+
61+
# date and other predicate
62+
query C rowsort
63+
select i_item_desc
64+
from test
65+
where d3_date > d2_date + INTERVAL '5 days' AND i_item_desc != 'g';
66+
----
67+
h
68+
69+
# swap predicate order
70+
query C rowsort
71+
select i_item_desc
72+
from test
73+
where i_item_desc != 'g' AND d3_date > d2_date + INTERVAL '5 days';
74+
----
75+
h
76+
77+
## Use OR
78+
query C rowsort
79+
select i_item_desc from test
80+
where d3_date > d2_date + INTERVAL '5 days'
81+
OR d3_date = d2_date + INTERVAL '3 days';
82+
----
83+
d
84+
g
85+
h

‎datafusion/core/tests/sqllogictests/test_files/timestamps.slt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,6 @@ select * from foo where ts != '2000-02-01T00:00:00';
6464
----
6565
1 2000-01-01T00:00:00
6666
3 2000-03-01T00:00:00
67+
68+
statement ok
69+
drop table foo;

0 commit comments

Comments
 (0)