Skip to content

Commit

Permalink
chore: fix flaky datetime test (#17188)
Browse files Browse the repository at this point in the history
  • Loading branch information
TCeason authored Jan 7, 2025
1 parent 18efd37 commit 2c73bdb
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 845 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,11 @@ select to_date('1947-04-15 00:00:00')
----
1947-04-15

query T
select to_date('1941-03-15 00:00:00')
----
1941-03-15

query T
select to_timestamp('1990-09-16 01:00:00');
----
Expand Down Expand Up @@ -852,6 +857,16 @@ set timezone='Asia/Shanghai';
statement ok
set enable_dst_hour_fix=1;

query T
select to_monday(to_date('1919-04-13','%Y-%m-%d'));
----
1919-04-07

query T
select to_year(to_date('1919-04-13','%Y-%m-%d'));
----
1919

query T
SELECT DATE_ADD(month, 1, '1941-03-15 00:00:00'::timestamp);
----
Expand Down Expand Up @@ -882,13 +897,12 @@ SELECT substr(DATE_ADD(month, 1, now())::String, 11)=substr(now()::String, 11);

# format: 11
query T
SELECT substr(DATE_ADD(month, 1, now())::String, 6, 2) =
CASE
WHEN substr(now()::String, 6, 2) = '12' THEN '01'
ELSE LPAD((substr(now()::String, 6, 2)::int + 1)::String, 2, '0')
END;
select sum( ((m1 + number) % 12 = m2 or ((m1 + number) % 12 + m2 = 12))::Int ) from (
select number, DATE_ADD(month, number, now()) as d, to_month(now()) as m1, to_month(d) as m2
from numbers(1000)
);
----
1
1000

# format: 2024
query T
Expand Down Expand Up @@ -947,13 +961,12 @@ SELECT substr(DATE_ADD(month, 1, now())::String, 11)=substr(now()::String, 11);

# format: 11
query T
SELECT substr(DATE_ADD(month, 1, now())::String, 6, 2) =
CASE
WHEN substr(now()::String, 6, 2) = '12' THEN '01'
ELSE LPAD((substr(now()::String, 6, 2)::int + 1)::String, 2, '0')
END;
select sum( ((m1 + number) % 12 = m2 or ((m1 + number) % 12 + m2 = 12))::Int ) from (
select number, DATE_ADD(month, number, now()) as d, to_month(now()) as m1, to_month(d) as m2
from numbers(1000)
);
----
1
1000

# format: 2024
query T
Expand Down Expand Up @@ -1066,3 +1079,43 @@ query T
select to_start_of_day('2024-11-14 11:54:33.667269');
----
2024-11-14 00:00:00.000000


statement ok
set enable_strict_datetime_parser = 0;

query T
select to_date('2017-5-23 0:00:00')
----
2017-05-23

query T
select to_date('2018-1-22')
----
2018-01-22

query T
select to_date('2021/10/14')
----
2021-10-14

query T
select to_date('20201231')
----
2020-12-31

query T
select to_date('2017-3-16 0:00:00')
----
2017-03-16

query T
select to_timestamp('2017-02-03 14:55:08 ');
----
2017-02-03 14:55:08.000000

statement error 1006
select to_timestamp('1684275059752');

statement ok
unset enable_strict_datetime_parser;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
statement ok
set enable_strict_datetime_parser = 0;

include ./02_0012_function_datetimes_tz.test

statement ok
unset enable_strict_datetime_parser;
Loading

0 comments on commit 2c73bdb

Please sign in to comment.