Skip to content

Commit 600eee6

Browse files
committed
Use backquotes around year, month, day, hour, minute and second
1 parent b292931 commit 600eee6

File tree

2 files changed

+23
-40
lines changed

2 files changed

+23
-40
lines changed

sql/core/src/test/resources/sql-tests/inputs/pgSQL/timestamp.sql

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,13 @@ SELECT '' AS date_trunc_week, date_trunc( 'week', timestamp '2004-02-29 15:44:17
186186
-- FROM TIMESTAMP_TBL
187187
-- WHERE d1 BETWEEN timestamp '1902-01-01'
188188
-- AND timestamp '2038-01-01';
189-
-- [SPARK-28767] ParseException: no viable alternative at input 'year'
190-
set spark.sql.parser.ansi.enabled=false;
189+
191190
SELECT '' AS `54`, d1 as `timestamp`,
192-
date_part( 'year', d1) AS year, date_part( 'month', d1) AS month,
193-
date_part( 'day', d1) AS day, date_part( 'hour', d1) AS hour,
194-
date_part( 'minute', d1) AS minute, date_part( 'second', d1) AS second
191+
date_part( 'year', d1) AS `year`, date_part( 'month', d1) AS `month`,
192+
date_part( 'day', d1) AS `day`, date_part( 'hour', d1) AS `hour`,
193+
date_part( 'minute', d1) AS `minute`, date_part( 'second', d1) AS `second`
195194
FROM TIMESTAMP_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01';
196-
set spark.sql.parser.ansi.enabled=true;
195+
197196
SELECT '' AS `54`, d1 as `timestamp`,
198197
date_part( 'quarter', d1) AS quarter, date_part( 'msec', d1) AS msec,
199198
date_part( 'usec', d1) AS usec

sql/core/src/test/resources/sql-tests/results/pgSQL/timestamp.sql.out

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Automatically generated by SQLQueryTestSuite
2-
-- Number of queries: 20
2+
-- Number of queries: 18
33

44

55
-- !query 0
@@ -123,75 +123,59 @@ struct<date_trunc_week:string,week_trunc:timestamp>
123123

124124

125125
-- !query 13
126-
set spark.sql.parser.ansi.enabled=false
127-
-- !query 13 schema
128-
struct<key:string,value:string>
129-
-- !query 13 output
130-
spark.sql.parser.ansi.enabled false
131-
132-
133-
-- !query 14
134126
SELECT '' AS `54`, d1 as `timestamp`,
135-
date_part( 'year', d1) AS year, date_part( 'month', d1) AS month,
136-
date_part( 'day', d1) AS day, date_part( 'hour', d1) AS hour,
137-
date_part( 'minute', d1) AS minute, date_part( 'second', d1) AS second
127+
date_part( 'year', d1) AS `year`, date_part( 'month', d1) AS `month`,
128+
date_part( 'day', d1) AS `day`, date_part( 'hour', d1) AS `hour`,
129+
date_part( 'minute', d1) AS `minute`, date_part( 'second', d1) AS `second`
138130
FROM TIMESTAMP_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01'
139-
-- !query 14 schema
131+
-- !query 13 schema
140132
struct<54:string,timestamp:timestamp,year:int,month:int,day:int,hour:int,minute:int,second:int>
141-
-- !query 14 output
133+
-- !query 13 output
142134
1997-01-02 00:00:00 1997 1 2 0 0 0
143135
1997-01-02 03:04:05 1997 1 2 3 4 5
144136
1997-02-10 17:32:01 1997 2 10 17 32 1
145137
2001-09-22 18:19:20 2001 9 22 18 19 20
146138

147139

148-
-- !query 15
149-
set spark.sql.parser.ansi.enabled=true
150-
-- !query 15 schema
151-
struct<key:string,value:string>
152-
-- !query 15 output
153-
spark.sql.parser.ansi.enabled true
154-
155-
156-
-- !query 16
140+
-- !query 14
157141
SELECT '' AS `54`, d1 as `timestamp`,
158142
date_part( 'quarter', d1) AS quarter, date_part( 'msec', d1) AS msec,
159143
date_part( 'usec', d1) AS usec
160144
FROM TIMESTAMP_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01'
161-
-- !query 16 schema
145+
-- !query 14 schema
162146
struct<54:string,timestamp:timestamp,quarter:int,msec:decimal(8,3),usec:int>
163-
-- !query 16 output
147+
-- !query 14 output
164148
1997-01-02 00:00:00 1 0 0
165149
1997-01-02 03:04:05 1 5000 5000000
166150
1997-02-10 17:32:01 1 1000 1000000
167151
2001-09-22 18:19:20 3 20000 20000000
168152

169153

170-
-- !query 17
154+
-- !query 15
171155
SELECT '' AS `54`, d1 as `timestamp`,
172156
date_part( 'isoyear', d1) AS isoyear, date_part( 'week', d1) AS week,
173157
date_part( 'dow', d1) AS dow
174158
FROM TIMESTAMP_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01'
175-
-- !query 17 schema
159+
-- !query 15 schema
176160
struct<54:string,timestamp:timestamp,isoyear:int,week:int,dow:int>
177-
-- !query 17 output
161+
-- !query 15 output
178162
1997-01-02 00:00:00 1997 1 4
179163
1997-01-02 03:04:05 1997 1 4
180164
1997-02-10 17:32:01 1997 7 1
181165
2001-09-22 18:19:20 2001 38 6
182166

183167

184-
-- !query 18
168+
-- !query 16
185169
SELECT make_timestamp(2014,12,28,6,30,45.887)
186-
-- !query 18 schema
170+
-- !query 16 schema
187171
struct<make_timestamp(2014, 12, 28, 6, 30, CAST(45.887 AS DECIMAL(8,6))):timestamp>
188-
-- !query 18 output
172+
-- !query 16 output
189173
2014-12-28 06:30:45.887
190174

191175

192-
-- !query 19
176+
-- !query 17
193177
DROP TABLE TIMESTAMP_TBL
194-
-- !query 19 schema
178+
-- !query 17 schema
195179
struct<>
196-
-- !query 19 output
180+
-- !query 17 output
197181

0 commit comments

Comments
 (0)