Skip to content

Commit 04642b3

Browse files
committed
Fix
1 parent 37d2e03 commit 04642b3

File tree

2 files changed

+152
-2
lines changed

2 files changed

+152
-2
lines changed

sql/core/src/test/resources/sql-tests/inputs/extract.sql

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,22 @@ select date_part(c, c) from t;
108108
select date_part(null, c) from t;
109109

110110
select date_part(i, i) from t;
111-
select date_part(null, i) from t;
111+
select date_part(null, i) from t;
112+
113+
-- In SPARK-31476, we've supported extract('field', source), too
114+
select extract('millennium', c) from t;
115+
select extract('century', c) from t;
116+
select extract('decade', c) from t;
117+
select extract('year', c) from t;
118+
select extract('quarter', c) from t;
119+
select extract('month', c) from t;
120+
select extract('week', c) from t;
121+
select extract('day', c) from t;
122+
select extract('days', c) from t;
123+
select extract('dayofweek', c) from t;
124+
select extract('dow', c) from t;
125+
select extract('isodow', c) from t;
126+
select extract('doy', c) from t;
127+
select extract('hour', c) from t;
128+
select extract('minute', c) from t;
129+
select extract('second', c) from t;

sql/core/src/test/resources/sql-tests/results/extract.sql.out

Lines changed: 133 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Automatically generated by SQLQueryTestSuite
2-
-- Number of queries: 84
2+
-- Number of queries: 100
33

44

55
-- !query
@@ -677,3 +677,135 @@ select date_part(null, i) from t
677677
struct<date_part(NULL, t.`i`):double>
678678
-- !query output
679679
NULL
680+
681+
682+
-- !query
683+
select extract('millennium', c) from t
684+
-- !query schema
685+
struct<>
686+
-- !query output
687+
org.apache.spark.sql.AnalysisException
688+
Literals of type 'millennium' are currently not supported for the string type.;; line 1 pos 7
689+
690+
691+
-- !query
692+
select extract('century', c) from t
693+
-- !query schema
694+
struct<>
695+
-- !query output
696+
org.apache.spark.sql.AnalysisException
697+
Literals of type 'century' are currently not supported for the string type.;; line 1 pos 7
698+
699+
700+
-- !query
701+
select extract('decade', c) from t
702+
-- !query schema
703+
struct<>
704+
-- !query output
705+
org.apache.spark.sql.AnalysisException
706+
Literals of type 'decade' are currently not supported for the string type.;; line 1 pos 7
707+
708+
709+
-- !query
710+
select extract('year', c) from t
711+
-- !query schema
712+
struct<extract('year' FROM t.`c`):int>
713+
-- !query output
714+
2011
715+
716+
717+
-- !query
718+
select extract('quarter', c) from t
719+
-- !query schema
720+
struct<extract('quarter' FROM t.`c`):int>
721+
-- !query output
722+
2
723+
724+
725+
-- !query
726+
select extract('month', c) from t
727+
-- !query schema
728+
struct<extract('month' FROM t.`c`):int>
729+
-- !query output
730+
5
731+
732+
733+
-- !query
734+
select extract('week', c) from t
735+
-- !query schema
736+
struct<extract('week' FROM t.`c`):int>
737+
-- !query output
738+
18
739+
740+
741+
-- !query
742+
select extract('day', c) from t
743+
-- !query schema
744+
struct<extract('day' FROM t.`c`):int>
745+
-- !query output
746+
6
747+
748+
749+
-- !query
750+
select extract('days', c) from t
751+
-- !query schema
752+
struct<extract('days' FROM t.`c`):int>
753+
-- !query output
754+
6
755+
756+
757+
-- !query
758+
select extract('dayofweek', c) from t
759+
-- !query schema
760+
struct<extract('dayofweek' FROM t.`c`):int>
761+
-- !query output
762+
6
763+
764+
765+
-- !query
766+
select extract('dow', c) from t
767+
-- !query schema
768+
struct<extract('dow' FROM t.`c`):int>
769+
-- !query output
770+
6
771+
772+
773+
-- !query
774+
select extract('isodow', c) from t
775+
-- !query schema
776+
struct<>
777+
-- !query output
778+
org.apache.spark.sql.AnalysisException
779+
Literals of type 'isodow' are currently not supported for the string type.;; line 1 pos 7
780+
781+
782+
-- !query
783+
select extract('doy', c) from t
784+
-- !query schema
785+
struct<extract('doy' FROM t.`c`):int>
786+
-- !query output
787+
126
788+
789+
790+
-- !query
791+
select extract('hour', c) from t
792+
-- !query schema
793+
struct<extract('hour' FROM t.`c`):int>
794+
-- !query output
795+
7
796+
797+
798+
-- !query
799+
select extract('minute', c) from t
800+
-- !query schema
801+
struct<extract('minute' FROM t.`c`):int>
802+
-- !query output
803+
8
804+
805+
806+
-- !query
807+
select extract('second', c) from t
808+
-- !query schema
809+
struct<extract('second' FROM t.`c`):decimal(8,6)>
810+
-- !query output
811+
9.123456

0 commit comments

Comments
 (0)