Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,328 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
sql/core/src/test/resources/sql-tests/inputs/datetime-formatting-invalid.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- TESTS FOR DATETIME FORMATTING FUNCTIONS WITH INVALID PATTERNS --- | ||
|
||
-- separating this from datetime-formatting.sql, because the text form | ||
-- for patterns with 5 letters in SimpleDateFormat varies from different JDKs | ||
select date_format('2018-11-17 13:33:33.333', 'GGGGG'); | ||
-- pattern letter count can not be greater than 10 | ||
select date_format('2018-11-17 13:33:33.333', 'yyyyyyyyyyy'); | ||
-- q/L in JDK 8 will fail when the count is more than 2 | ||
select date_format('2018-11-17 13:33:33.333', 'qqqqq'); | ||
select date_format('2018-11-17 13:33:33.333', 'QQQQQ'); | ||
select date_format('2018-11-17 13:33:33.333', 'MMMMM'); | ||
select date_format('2018-11-17 13:33:33.333', 'LLLLL'); | ||
|
||
select date_format('2018-11-17 13:33:33.333', 'EEEEE'); | ||
select date_format('2018-11-17 13:33:33.333', 'FF'); | ||
select date_format('2018-11-17 13:33:33.333', 'ddd'); | ||
-- DD is invalid if the day-of-year exceeds 100, but it becomes valid in Java 11 | ||
-- select date_format('2018-11-17 13:33:33.333', 'DD'); | ||
select date_format('2018-11-17 13:33:33.333', 'DDDD'); | ||
select date_format('2018-11-17 13:33:33.333', 'HHH'); | ||
select date_format('2018-11-17 13:33:33.333', 'hhh'); | ||
select date_format('2018-11-17 13:33:33.333', 'kkk'); | ||
select date_format('2018-11-17 13:33:33.333', 'KKK'); | ||
select date_format('2018-11-17 13:33:33.333', 'mmm'); | ||
select date_format('2018-11-17 13:33:33.333', 'sss'); | ||
select date_format('2018-11-17 13:33:33.333', 'SSSSSSSSSS'); | ||
select date_format('2018-11-17 13:33:33.333', 'aa'); | ||
select date_format('2018-11-17 13:33:33.333', 'V'); | ||
select date_format('2018-11-17 13:33:33.333', 'zzzzz'); | ||
select date_format('2018-11-17 13:33:33.333', 'XXXXXX'); | ||
select date_format('2018-11-17 13:33:33.333', 'ZZZZZZ'); | ||
select date_format('2018-11-17 13:33:33.333', 'OO'); | ||
select date_format('2018-11-17 13:33:33.333', 'xxxxxx'); | ||
|
||
select date_format('2018-11-17 13:33:33.333', 'A'); | ||
select date_format('2018-11-17 13:33:33.333', 'n'); | ||
select date_format('2018-11-17 13:33:33.333', 'N'); | ||
select date_format('2018-11-17 13:33:33.333', 'p'); | ||
|
||
-- disabled week-based patterns | ||
select date_format('2018-11-17 13:33:33.333', 'Y'); | ||
select date_format('2018-11-17 13:33:33.333', 'w'); | ||
select date_format('2018-11-17 13:33:33.333', 'W'); | ||
select date_format('2018-11-17 13:33:33.333', 'u'); | ||
select date_format('2018-11-17 13:33:33.333', 'e'); | ||
select date_format('2018-11-17 13:33:33.333', 'c'); | ||
|
||
-- others | ||
select date_format('2018-11-17 13:33:33.333', 'B'); | ||
select date_format('2018-11-17 13:33:33.333', 'C'); | ||
select date_format('2018-11-17 13:33:33.333', 'I'); | ||
|
||
|
2 changes: 2 additions & 0 deletions
2
sql/core/src/test/resources/sql-tests/inputs/datetime-formatting-legacy.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--SET spark.sql.legacy.timeParserPolicy=LEGACY | ||
--IMPORT datetime-formatting.sql |
68 changes: 68 additions & 0 deletions
68
sql/core/src/test/resources/sql-tests/inputs/datetime-formatting.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- TESTS FOR DATETIME FORMATTING FUNCTIONS --- | ||
|
||
create temporary view v as select col from values | ||
(timestamp '1582-06-01 11:33:33.123UTC+080000'), | ||
(timestamp '1970-01-01 00:00:00.000Europe/Paris'), | ||
(timestamp '1970-12-31 23:59:59.999Asia/Srednekolymsk'), | ||
(timestamp '1996-04-01 00:33:33.123Australia/Darwin'), | ||
(timestamp '2018-11-17 13:33:33.123Z'), | ||
(timestamp '2020-01-01 01:33:33.123Asia/Shanghai'), | ||
(timestamp '2100-01-01 01:33:33.123America/Los_Angeles') t(col); | ||
|
||
select col, date_format(col, 'G GG GGG GGGG') from v; | ||
|
||
select col, date_format(col, 'y yy yyy yyyy yyyyy yyyyyy yyyyyyy yyyyyyyy yyyyyyyyy yyyyyyyyyy') from v; | ||
|
||
select col, date_format(col, 'q qq') from v; | ||
|
||
select col, date_format(col, 'Q QQ QQQ QQQQ') from v; | ||
|
||
select col, date_format(col, 'M MM MMM MMMM') from v; | ||
|
||
select col, date_format(col, 'L LL') from v; | ||
|
||
select col, date_format(col, 'E EE EEE EEEE') from v; | ||
|
||
select col, date_format(col, 'F') from v; | ||
|
||
select col, date_format(col, 'd dd') from v; | ||
|
||
select col, date_format(col, 'DD') from v where col = timestamp '2100-01-01 01:33:33.123America/Los_Angeles'; | ||
select col, date_format(col, 'D DDD') from v; | ||
|
||
select col, date_format(col, 'H HH') from v; | ||
|
||
select col, date_format(col, 'h hh') from v; | ||
|
||
select col, date_format(col, 'k kk') from v; | ||
|
||
select col, date_format(col, 'K KK') from v; | ||
|
||
select col, date_format(col, 'm mm') from v; | ||
|
||
select col, date_format(col, 's ss') from v; | ||
|
||
select col, date_format(col, 'S SS SSS SSSS SSSSS SSSSSS SSSSSSS SSSSSSSS SSSSSSSSS') from v; | ||
|
||
select col, date_format(col, 'a') from v; | ||
|
||
select col, date_format(col, 'VV') from v; | ||
|
||
select col, date_format(col, 'z zz zzz zzzz') from v; | ||
|
||
select col, date_format(col, 'X XX XXX') from v; | ||
select col, date_format(col, 'XXXX XXXXX') from v; | ||
|
||
select col, date_format(col, 'Z ZZ ZZZ ZZZZ ZZZZZ') from v; | ||
|
||
select col, date_format(col, 'O OOOO') from v; | ||
|
||
select col, date_format(col, 'x xx xxx xxxx xxxx xxxxx') from v; | ||
|
||
-- optional pattern, but the results won't be optional for formatting | ||
select col, date_format(col, '[yyyy-MM-dd HH:mm:ss]') from v; | ||
|
||
-- literals | ||
select col, date_format(col, "姚123'GyYqQMLwWuEFDdhHmsSaVzZxXOV'") from v; | ||
select col, date_format(col, "''") from v; | ||
select col, date_format(col, '') from v; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.