-
Notifications
You must be signed in to change notification settings - Fork 28.2k
/
udf-aggregates_part1.sql.out
387 lines (300 loc) · 7.93 KB
/
udf-aggregates_part1.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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
-- Automatically generated by SQLQueryTestSuite
-- Number of queries: 43
-- !query
SELECT avg(udf(four)) AS avg_1 FROM onek
-- !query schema
struct<avg_1:double>
-- !query output
1.5
-- !query
SELECT udf(avg(a)) AS avg_32 FROM aggtest WHERE a < 100
-- !query schema
struct<avg_32:double>
-- !query output
32.666666666666664
-- !query
select CAST(avg(udf(b)) AS Decimal(10,3)) AS avg_107_943 FROM aggtest
-- !query schema
struct<avg_107_943:decimal(10,3)>
-- !query output
107.943
-- !query
SELECT sum(udf(four)) AS sum_1500 FROM onek
-- !query schema
struct<sum_1500:bigint>
-- !query output
1500
-- !query
SELECT udf(sum(a)) AS sum_198 FROM aggtest
-- !query schema
struct<sum_198:bigint>
-- !query output
198
-- !query
SELECT udf(udf(sum(b))) AS avg_431_773 FROM aggtest
-- !query schema
struct<avg_431_773:double>
-- !query output
431.77260909229517
-- !query
SELECT udf(max(four)) AS max_3 FROM onek
-- !query schema
struct<max_3:int>
-- !query output
3
-- !query
SELECT max(udf(a)) AS max_100 FROM aggtest
-- !query schema
struct<max_100:int>
-- !query output
100
-- !query
SELECT udf(udf(max(aggtest.b))) AS max_324_78 FROM aggtest
-- !query schema
struct<max_324_78:float>
-- !query output
324.78
-- !query
SELECT stddev_pop(udf(b)) FROM aggtest
-- !query schema
struct<stddev_pop(udf(b)):double>
-- !query output
131.10703231895047
-- !query
SELECT udf(stddev_samp(b)) FROM aggtest
-- !query schema
struct<udf(stddev_samp(b)):double>
-- !query output
151.38936080399804
-- !query
SELECT var_pop(udf(b)) FROM aggtest
-- !query schema
struct<var_pop(udf(b)):double>
-- !query output
17189.053923482323
-- !query
SELECT udf(var_samp(b)) FROM aggtest
-- !query schema
struct<udf(var_samp(b)):double>
-- !query output
22918.738564643096
-- !query
SELECT udf(stddev_pop(CAST(b AS Decimal(38,0)))) FROM aggtest
-- !query schema
struct<udf(stddev_pop(CAST(b AS DECIMAL(38,0)))):double>
-- !query output
131.18117242958306
-- !query
SELECT stddev_samp(CAST(udf(b) AS Decimal(38,0))) FROM aggtest
-- !query schema
struct<stddev_samp(CAST(udf(b) AS DECIMAL(38,0))):double>
-- !query output
151.47497042966097
-- !query
SELECT udf(var_pop(CAST(b AS Decimal(38,0)))) FROM aggtest
-- !query schema
struct<udf(var_pop(CAST(b AS DECIMAL(38,0)))):double>
-- !query output
17208.5
-- !query
SELECT var_samp(udf(CAST(b AS Decimal(38,0)))) FROM aggtest
-- !query schema
struct<var_samp(udf(CAST(b AS DECIMAL(38,0)))):double>
-- !query output
22944.666666666668
-- !query
SELECT udf(var_pop(1.0)), var_samp(udf(2.0))
-- !query schema
struct<udf(var_pop(1.0)):double,var_samp(udf(2.0)):double>
-- !query output
0.0 NULL
-- !query
SELECT stddev_pop(udf(CAST(3.0 AS Decimal(38,0)))), stddev_samp(CAST(udf(4.0) AS Decimal(38,0)))
-- !query schema
struct<stddev_pop(udf(CAST(3.0 AS DECIMAL(38,0)))):double,stddev_samp(CAST(udf(4.0) AS DECIMAL(38,0))):double>
-- !query output
0.0 NULL
-- !query
select sum(udf(CAST(null AS int))) from range(1,4)
-- !query schema
struct<sum(udf(CAST(NULL AS INT))):bigint>
-- !query output
NULL
-- !query
select sum(udf(CAST(null AS long))) from range(1,4)
-- !query schema
struct<sum(udf(CAST(NULL AS BIGINT))):bigint>
-- !query output
NULL
-- !query
select sum(udf(CAST(null AS Decimal(38,0)))) from range(1,4)
-- !query schema
struct<sum(udf(CAST(NULL AS DECIMAL(38,0)))):decimal(38,0)>
-- !query output
NULL
-- !query
select sum(udf(CAST(null AS DOUBLE))) from range(1,4)
-- !query schema
struct<sum(udf(CAST(NULL AS DOUBLE))):double>
-- !query output
NULL
-- !query
select avg(udf(CAST(null AS int))) from range(1,4)
-- !query schema
struct<avg(udf(CAST(NULL AS INT))):double>
-- !query output
NULL
-- !query
select avg(udf(CAST(null AS long))) from range(1,4)
-- !query schema
struct<avg(udf(CAST(NULL AS BIGINT))):double>
-- !query output
NULL
-- !query
select avg(udf(CAST(null AS Decimal(38,0)))) from range(1,4)
-- !query schema
struct<avg(udf(CAST(NULL AS DECIMAL(38,0)))):decimal(38,4)>
-- !query output
NULL
-- !query
select avg(udf(CAST(null AS DOUBLE))) from range(1,4)
-- !query schema
struct<avg(udf(CAST(NULL AS DOUBLE))):double>
-- !query output
NULL
-- !query
select sum(CAST(udf('NaN') AS DOUBLE)) from range(1,4)
-- !query schema
struct<sum(CAST(udf(NaN) AS DOUBLE)):double>
-- !query output
NaN
-- !query
select avg(CAST(udf('NaN') AS DOUBLE)) from range(1,4)
-- !query schema
struct<avg(CAST(udf(NaN) AS DOUBLE)):double>
-- !query output
NaN
-- !query
SELECT avg(CAST(udf(x) AS DOUBLE)), var_pop(CAST(udf(x) AS DOUBLE))
FROM (VALUES ('Infinity'), ('1')) v(x)
-- !query schema
struct<avg(CAST(udf(x) AS DOUBLE)):double,var_pop(CAST(udf(x) AS DOUBLE)):double>
-- !query output
Infinity NaN
-- !query
SELECT avg(CAST(udf(x) AS DOUBLE)), var_pop(CAST(udf(x) AS DOUBLE))
FROM (VALUES ('Infinity'), ('Infinity')) v(x)
-- !query schema
struct<avg(CAST(udf(x) AS DOUBLE)):double,var_pop(CAST(udf(x) AS DOUBLE)):double>
-- !query output
Infinity NaN
-- !query
SELECT avg(CAST(udf(x) AS DOUBLE)), var_pop(CAST(udf(x) AS DOUBLE))
FROM (VALUES ('-Infinity'), ('Infinity')) v(x)
-- !query schema
struct<avg(CAST(udf(x) AS DOUBLE)):double,var_pop(CAST(udf(x) AS DOUBLE)):double>
-- !query output
NaN NaN
-- !query
SELECT avg(udf(CAST(x AS DOUBLE))), udf(var_pop(CAST(x AS DOUBLE)))
FROM (VALUES (100000003), (100000004), (100000006), (100000007)) v(x)
-- !query schema
struct<avg(udf(CAST(x AS DOUBLE))):double,udf(var_pop(CAST(x AS DOUBLE))):double>
-- !query output
1.00000005E8 2.5
-- !query
SELECT avg(udf(CAST(x AS DOUBLE))), udf(var_pop(CAST(x AS DOUBLE)))
FROM (VALUES (7000000000005), (7000000000007)) v(x)
-- !query schema
struct<avg(udf(CAST(x AS DOUBLE))):double,udf(var_pop(CAST(x AS DOUBLE))):double>
-- !query output
7.000000000006E12 1.0
-- !query
SELECT udf(covar_pop(b, udf(a))), covar_samp(udf(b), a) FROM aggtest
-- !query schema
struct<udf(covar_pop(b, udf(a))):double,covar_samp(udf(b), a):double>
-- !query output
653.6289553875104 871.5052738500139
-- !query
SELECT corr(b, udf(a)) FROM aggtest
-- !query schema
struct<corr(b, udf(a)):double>
-- !query output
0.1396345165178734
-- !query
SELECT count(udf(four)) AS cnt_1000 FROM onek
-- !query schema
struct<cnt_1000:bigint>
-- !query output
1000
-- !query
SELECT udf(count(DISTINCT four)) AS cnt_4 FROM onek
-- !query schema
struct<cnt_4:bigint>
-- !query output
4
-- !query
select ten, udf(count(*)), sum(udf(four)) from onek
group by ten order by ten
-- !query schema
struct<ten:int,udf(count(1)):bigint,sum(udf(four)):bigint>
-- !query output
0 100 100
1 100 200
2 100 100
3 100 200
4 100 100
5 100 200
6 100 100
7 100 200
8 100 100
9 100 200
-- !query
select ten, count(udf(four)), udf(sum(DISTINCT four)) from onek
group by ten order by ten
-- !query schema
struct<ten:int,count(udf(four)):bigint,udf(sum(DISTINCT four)):bigint>
-- !query output
0 100 2
1 100 4
2 100 2
3 100 4
4 100 2
5 100 4
6 100 2
7 100 4
8 100 2
9 100 4
-- !query
select ten, udf(sum(distinct four)) from onek a
group by ten
having exists (select 1 from onek b where udf(sum(distinct a.four)) = b.four)
-- !query schema
struct<ten:int,udf(sum(DISTINCT four)):bigint>
-- !query output
0 2
2 2
4 2
6 2
8 2
-- !query
select ten, sum(distinct four) from onek a
group by ten
having exists (select 1 from onek b
where sum(distinct a.four + b.four) = udf(b.four))
-- !query schema
struct<>
-- !query output
org.apache.spark.sql.AnalysisException
Aggregate/Window/Generate expressions are not valid in where clause of the query.
Expression in where clause: [(sum(DISTINCT (outer(a.four) + b.four)) = CAST(CAST(udf(ansi_cast(four as string)) AS INT) AS BIGINT))]
Invalid expressions: [sum(DISTINCT (outer(a.four) + b.four))]
-- !query
select
(select udf(max((select i.unique2 from tenk1 i where i.unique1 = o.unique1))))
from tenk1 o
-- !query schema
struct<>
-- !query output
org.apache.spark.sql.AnalysisException
cannot resolve 'o.unique1' given input columns: [i.even, i.fivethous, i.four, i.hundred, i.odd, i.string4, i.stringu1, i.stringu2, i.ten, i.tenthous, i.thousand, i.twenty, i.two, i.twothousand, i.unique1, i.unique2]; line 2 pos 67