Skip to content

Commit 4d34f44

Browse files
committed
update test
1 parent 83499a1 commit 4d34f44

File tree

5 files changed

+381
-661
lines changed

5 files changed

+381
-661
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
--- TESTS FOR DATETIME FORMATTING FUNCTIONS WITH INVALID PATTERNS ---
2+
3+
-- separating this from datetime-formatting.sql ,because the text form
4+
-- for patterns with 5 letters in SimpleDateFormat varies from different JDKs
5+
create temporary view v as select col from values
6+
(timestamp '1582-06-01 11:33:33.123UTC+080000'),
7+
(timestamp '1970-01-01 00:00:00.000Europe/Paris'),
8+
(timestamp '1970-12-31 23:59:59.999Asia/Srednekolymsk'),
9+
(timestamp '1996-04-01 00:33:33.123Australia/Darwin'),
10+
(timestamp '2018-11-17 13:33:33.123Z'),
11+
(timestamp '2020-01-01 01:33:33.123Asia/Shanghai'),
12+
(timestamp '2100-01-01 01:33:33.123America/Los_Angeles') t(col);
13+
14+
select col, date_format(col, 'GGGGG') from v;
15+
select col, date_format(col, 'yyyyyyyyyyy') from v; -- pattern letter count can not be greater than 10
16+
select col, date_format(col, 'YYYYYYYYYYY') from v;
17+
-- q/L in JDK 8 will fail when the count is more than 2
18+
select col, date_format(col, 'qqqqq') from v;
19+
select col, date_format(col, 'QQQQQ') from v;
20+
select col, date_format(col, 'MMMMM') from v;
21+
select col, date_format(col, 'LLLLL') from v;
22+
select col, date_format(col, 'www') from v;
23+
select col, date_format(col, 'WW') from v;
24+
select col, date_format(col, 'uuuuu') from v;
25+
select col, date_format(col, 'EEEEE') from v;
26+
select col, date_format(col, 'FF') from v;
27+
select col, date_format(col, 'ddd') from v;
28+
select col, date_format(col, 'DD') from v;
29+
select col, date_format(col, 'DDDD') from v;
30+
select col, date_format(col, 'HHH') from v;
31+
select col, date_format(col, 'hhh') from v;
32+
select col, date_format(col, 'kkk') from v;
33+
select col, date_format(col, 'KKK') from v;
34+
select col, date_format(col, 'mmm') from v;
35+
select col, date_format(col, 'sss') from v;
36+
select col, date_format(col, 'SSSSSSSSSS') from v;
37+
select col, date_format(col, 'aa') from v;
38+
select col, date_format(col, 'V') from v;
39+
select col, date_format(col, 'zzzzz') from v;
40+
select col, date_format(col, 'XXXXXX') from v;
41+
select col, date_format(col, 'ZZZZZZ') from v;
42+
select col, date_format(col, 'OO') from v;
43+
select col, date_format(col, 'xxxxxx') from v;

sql/core/src/test/resources/sql-tests/inputs/datetime-formatting.sql

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,86 +9,66 @@ create temporary view v as select col from values
99
(timestamp '2020-01-01 01:33:33.123Asia/Shanghai'),
1010
(timestamp '2100-01-01 01:33:33.123America/Los_Angeles') t(col);
1111

12-
--------------------------- '1 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890'
1312
select col, date_format(col, 'G GG GGG GGGG') from v;
14-
select col, date_format(col, 'GGGGG') from v;
1513

1614
select col, date_format(col, 'y yy yyy yyyy yyyyy yyyyyy yyyyyyy yyyyyyyy yyyyyyyyy yyyyyyyyyy') from v;
17-
select col, date_format(col, 'yyyyyyyyyyy') from v;
1815

1916
select col, date_format(col, 'Y YY YYY YYYY YYYYY YYYYYY YYYYYYY YYYYYYYY YYYYYYYYY YYYYYYYYYY') from v;
20-
select col, date_format(col, 'YYYYYYYYYYY') from v;
2117

2218
select col, date_format(col, 'q qq') from v;
23-
select col, date_format(col, 'qqq') from v;
2419

2520
select col, date_format(col, 'Q QQ QQQ QQQQ') from v;
26-
select col, date_format(col, 'QQQQQ') from v;
2721

2822
select col, date_format(col, 'M MM MMM MMMM') from v;
29-
select col, date_format(col, 'MMMMM') from v;
3023

3124
select col, date_format(col, 'L LL') from v;
32-
select col, date_format(col, 'LLL') from v;
3325

3426
select col, date_format(col, 'w ww') from v;
35-
select col, date_format(col, 'www') from v;
3627

3728
select col, date_format(col, 'W') from v;
38-
select col, date_format(col, 'WW') from v;
3929

4030
select col, date_format(col, 'u uu uuu uuuu') from v;
41-
select col, date_format(col, 'uuuuu') from v;
4231

4332
select col, date_format(col, 'E EE EEE EEEE') from v;
44-
select col, date_format(col, 'EEEEE') from v;
4533

4634
select col, date_format(col, 'F') from v;
47-
select col, date_format(col, 'FF') from v;
4835

4936
select col, date_format(col, 'd dd') from v;
50-
select col, date_format(col, 'ddd') from v;
5137

5238
select col, date_format(col, 'DD') from v where col = timestamp '2100-01-01 01:33:33.123America/Los_Angeles';
53-
select col, date_format(col, 'DD') from v;
5439
select col, date_format(col, 'D DDD') from v;
55-
select col, date_format(col, 'DDDD') from v;
5640

5741
select col, date_format(col, 'H HH') from v;
58-
select col, date_format(col, 'HHH') from v;
5942

6043
select col, date_format(col, 'h hh') from v;
61-
select col, date_format(col, 'hhh') from v;
6244

6345
select col, date_format(col, 'k kk') from v;
64-
select col, date_format(col, 'kkk') from v;
6546

6647
select col, date_format(col, 'K KK') from v;
67-
select col, date_format(col, 'KKK') from v;
6848

6949
select col, date_format(col, 'm mm') from v;
70-
select col, date_format(col, 'mmm') from v;
7150

7251
select col, date_format(col, 's ss') from v;
73-
select col, date_format(col, 'sss') from v;
7452

7553
select col, date_format(col, 'S SS SSS SSSS SSSSS SSSSSS SSSSSSS SSSSSSSS SSSSSSSSS') from v;
76-
select col, date_format(col, 'SSSSSSSSSS') from v;
7754

78-
select col, date_format(col, 'a') from v;
79-
select col, date_format(col, 'aa') from v;
55+
-- add upper function here to avoid
56+
select col, upper(date_format(col, 'a')) from v;
8057

8158
select col, date_format(col, 'VV') from v;
82-
select col, date_format(col, 'V') from v;
8359

8460
select col, date_format(col, 'z zz zzz zzzz') from v;
85-
select col, date_format(col, 'zzzzz') from v;
61+
8662
select col, date_format(col, 'X XX XXX') from v;
8763
select col, date_format(col, 'XXXX XXXXX') from v;
88-
select col, date_format(col, 'XXXXXX') from v;
64+
8965
select col, date_format(col, 'Z ZZ ZZZ ZZZZ ZZZZZ') from v;
90-
select col, date_format(col, 'ZZZZZZ') from v;
66+
9167
select col, date_format(col, 'O OOOO') from v;
92-
select col, date_format(col, 'OO') from v;
68+
9369
select col, date_format(col, 'x xx xxx xxxx xxxx xxxxx') from v;
94-
select col, date_format(col, 'xxxxxx') from v;
70+
71+
-- optional pattern, but the results won't be optional for formatting
72+
select col, date_format(col, '[yyyy-MM-dd HH:mm:ss]') from v;
73+
74+
select col, date_format(col, "姚123'GyYqQMLwWuEFDdhHmsSaVzZxXOV'") from v; -- literals

0 commit comments

Comments
 (0)