/
stringCastAndExpressions.sql.out
264 lines (199 loc) · 5.03 KB
/
stringCastAndExpressions.sql.out
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
-- Automatically generated by SQLQueryTestSuite
-- Number of queries: 32
-- !query
CREATE TEMPORARY VIEW t AS SELECT 'aa' as a
-- !query schema
struct<>
-- !query output
-- !query
select cast(a as byte) from t
-- !query schema
struct<a:tinyint>
-- !query output
NULL
-- !query
select cast(a as short) from t
-- !query schema
struct<a:smallint>
-- !query output
NULL
-- !query
select cast(a as int) from t
-- !query schema
struct<a:int>
-- !query output
NULL
-- !query
select cast(a as long) from t
-- !query schema
struct<a:bigint>
-- !query output
NULL
-- !query
select cast(a as float) from t
-- !query schema
struct<a:float>
-- !query output
NULL
-- !query
select cast(a as double) from t
-- !query schema
struct<a:double>
-- !query output
NULL
-- !query
select cast(a as decimal) from t
-- !query schema
struct<a:decimal(10,0)>
-- !query output
NULL
-- !query
select cast(a as boolean) from t
-- !query schema
struct<a:boolean>
-- !query output
NULL
-- !query
select cast(a as timestamp) from t
-- !query schema
struct<a:timestamp>
-- !query output
NULL
-- !query
select cast(a as date) from t
-- !query schema
struct<a:date>
-- !query output
NULL
-- !query
select cast(a as binary) from t
-- !query schema
struct<a:binary>
-- !query output
aa
-- !query
select cast(a as array<string>) from t
-- !query schema
struct<>
-- !query output
org.apache.spark.sql.AnalysisException
cannot resolve 't.a' due to data type mismatch: cannot cast string to array<string>; line 1 pos 7
-- !query
select cast(a as struct<s:string>) from t
-- !query schema
struct<>
-- !query output
org.apache.spark.sql.AnalysisException
cannot resolve 't.a' due to data type mismatch: cannot cast string to struct<s:string>; line 1 pos 7
-- !query
select cast(a as map<string, string>) from t
-- !query schema
struct<>
-- !query output
org.apache.spark.sql.AnalysisException
cannot resolve 't.a' due to data type mismatch: cannot cast string to map<string,string>; line 1 pos 7
-- !query
select to_timestamp(a) from t
-- !query schema
struct<to_timestamp(a):timestamp>
-- !query output
NULL
-- !query
select to_timestamp('2018-01-01', a) from t
-- !query schema
struct<>
-- !query output
org.apache.spark.SparkUpgradeException
You may get a different result due to the upgrading of Spark 3.0: Fail to recognize 'aa' pattern in the DateTimeFormatter. 1) You can set spark.sql.legacy.timeParserPolicy to LEGACY to restore the behavior before Spark 3.0. 2) You can form a valid datetime pattern with the guide from https://spark.apache.org/docs/latest/sql-ref-datetime-pattern.html
-- !query
select to_unix_timestamp(a) from t
-- !query schema
struct<to_unix_timestamp(a, yyyy-MM-dd HH:mm:ss):bigint>
-- !query output
NULL
-- !query
select to_unix_timestamp('2018-01-01', a) from t
-- !query schema
struct<>
-- !query output
org.apache.spark.SparkUpgradeException
You may get a different result due to the upgrading of Spark 3.0: Fail to recognize 'aa' pattern in the DateTimeFormatter. 1) You can set spark.sql.legacy.timeParserPolicy to LEGACY to restore the behavior before Spark 3.0. 2) You can form a valid datetime pattern with the guide from https://spark.apache.org/docs/latest/sql-ref-datetime-pattern.html
-- !query
select unix_timestamp(a) from t
-- !query schema
struct<unix_timestamp(a, yyyy-MM-dd HH:mm:ss):bigint>
-- !query output
NULL
-- !query
select unix_timestamp('2018-01-01', a) from t
-- !query schema
struct<>
-- !query output
org.apache.spark.SparkUpgradeException
You may get a different result due to the upgrading of Spark 3.0: Fail to recognize 'aa' pattern in the DateTimeFormatter. 1) You can set spark.sql.legacy.timeParserPolicy to LEGACY to restore the behavior before Spark 3.0. 2) You can form a valid datetime pattern with the guide from https://spark.apache.org/docs/latest/sql-ref-datetime-pattern.html
-- !query
select from_unixtime(a) from t
-- !query schema
struct<from_unixtime(a, yyyy-MM-dd HH:mm:ss):string>
-- !query output
NULL
-- !query
select from_unixtime('2018-01-01', a) from t
-- !query schema
struct<from_unixtime(2018-01-01, a):string>
-- !query output
NULL
-- !query
select next_day(a, 'MO') from t
-- !query schema
struct<next_day(a, MO):date>
-- !query output
NULL
-- !query
select next_day('2018-01-01', a) from t
-- !query schema
struct<next_day(2018-01-01, a):date>
-- !query output
NULL
-- !query
select trunc(a, 'MM') from t
-- !query schema
struct<trunc(a, MM):date>
-- !query output
NULL
-- !query
select trunc('2018-01-01', a) from t
-- !query schema
struct<trunc(2018-01-01, a):date>
-- !query output
NULL
-- !query
select unhex('-123')
-- !query schema
struct<unhex(-123):binary>
-- !query output
NULL
-- !query
select sha2(a, a) from t
-- !query schema
struct<sha2(a, a):string>
-- !query output
NULL
-- !query
select get_json_object(a, a) from t
-- !query schema
struct<get_json_object(a, a):string>
-- !query output
NULL
-- !query
select json_tuple(a, a) from t
-- !query schema
struct<c0:string>
-- !query output
NULL
-- !query
select from_json(a, 'a INT') from t
-- !query schema
struct<from_json(a):struct<a:int>>
-- !query output
{"a":null}