Skip to content

Commit efb5ece

Browse files
committed
fix breaking tests
1 parent 9a98510 commit efb5ece

File tree

2 files changed

+34
-44
lines changed

2 files changed

+34
-44
lines changed

sql/core/src/test/resources/sql-tests/inputs/udf/udf-pivot.sql

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
-- This test file was converted from pivot.sql.
22

3-
-- Note that currently registered UDF returns a string. So there are some differences, for instance
4-
-- in string cast within UDF in Scala and Python.
5-
63
--Note some test cases have been commented as the current integrated UDFs cannot handle complex types
74

85
create temporary view courseSales as select * from values
@@ -66,7 +63,6 @@ PIVOT (
6663
FOR course IN ('dotNET', 'Java')
6764
);
6865

69-
--todo nan fix
7066
-- pivot on join query with multiple group by columns
7167
SELECT * FROM (
7268
SELECT course, year, earnings, udf(s) as s
@@ -161,7 +157,6 @@ PIVOT (
161157
FOR course IN ('dotNET', 'Java')
162158
);
163159

164-
--todo nan fix
165160
-- pivot on multiple pivot columns
166161
SELECT * FROM (
167162
SELECT course, year, earnings, s
@@ -173,7 +168,6 @@ PIVOT (
173168
FOR (course, year) IN (('dotNET', 2012), ('Java', 2013))
174169
);
175170

176-
--todo nan fix
177171
-- pivot on multiple pivot columns with aliased values
178172
SELECT * FROM (
179173
SELECT course, year, earnings, s
@@ -234,7 +228,6 @@ PIVOT (
234228
-- FOR (y, course) IN ((2012, 'dotNET'), (2013, 'Java'))
235229
--);
236230

237-
--todo nan fix
238231
-- pivot on pivot column of array type
239232
SELECT * FROM (
240233
SELECT earnings, year, a
@@ -246,7 +239,6 @@ PIVOT (
246239
FOR a IN (array(1, 1), array(2, 2))
247240
);
248241

249-
--todo nan fix
250242
-- pivot on multiple pivot columns containing array type
251243
SELECT * FROM (
252244
SELECT course, earnings, year, a
@@ -258,7 +250,6 @@ PIVOT (
258250
FOR (course, a) IN (('dotNET', array(1, 1)), ('Java', array(2, 2)))
259251
);
260252

261-
--todo nan fix
262253
-- pivot on pivot column of struct type
263254
SELECT * FROM (
264255
SELECT earnings, year, s
@@ -270,7 +261,6 @@ PIVOT (
270261
FOR s IN ((1, 'a'), (2, 'b'))
271262
);
272263

273-
--todo nan fix
274264
-- pivot on multiple pivot columns containing struct type
275265
SELECT * FROM (
276266
SELECT course, earnings, year, s

sql/core/src/test/resources/sql-tests/results/udf/udf-pivot.sql.out

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ PIVOT (
4747
FOR course IN ('dotNET', 'Java')
4848
)
4949
-- !query 3 schema
50-
struct<udf(year):string,dotNET:string,Java:string>
50+
struct<CAST(udf(cast(year as string)) AS INT):int,dotNET:bigint,Java:bigint>
5151
-- !query 3 output
5252
2012 15000 20000
5353
2013 48000 30000
@@ -60,7 +60,7 @@ PIVOT (
6060
FOR year IN (2012, 2013)
6161
)
6262
-- !query 4 schema
63-
struct<course:string,2012:string,2013:string>
63+
struct<course:string,2012:bigint,2013:bigint>
6464
-- !query 4 output
6565
Java 20000 30000
6666
dotNET 15000 48000
@@ -75,7 +75,7 @@ PIVOT (
7575
FOR course IN ('dotNET', 'Java')
7676
)
7777
-- !query 5 schema
78-
struct<year:int,dotNET_udf(sum(cast(earnings as bigint))):string,dotNET_udf(avg(cast(earnings as bigint))):string,Java_udf(sum(cast(earnings as bigint))):string,Java_udf(avg(cast(earnings as bigint))):string>
78+
struct<year:int,dotNET_CAST(udf(cast(sum(cast(earnings as bigint)) as string)) AS BIGINT):bigint,dotNET_CAST(udf(cast(avg(cast(earnings as bigint)) as string)) AS DOUBLE):double,Java_CAST(udf(cast(sum(cast(earnings as bigint)) as string)) AS BIGINT):bigint,Java_CAST(udf(cast(avg(cast(earnings as bigint)) as string)) AS DOUBLE):double>
7979
-- !query 5 output
8080
2012 15000 7500.0 20000 20000.0
8181
2013 48000 48000.0 30000 30000.0
@@ -90,7 +90,7 @@ PIVOT (
9090
FOR course IN ('dotNET', 'Java')
9191
)
9292
-- !query 6 schema
93-
struct<dotNET:string,Java:string>
93+
struct<dotNET:bigint,Java:bigint>
9494
-- !query 6 output
9595
63000 50000
9696

@@ -104,7 +104,7 @@ PIVOT (
104104
FOR course IN ('dotNET', 'Java')
105105
)
106106
-- !query 7 schema
107-
struct<dotNET_udf(sum(cast(earnings as bigint))):string,dotNET_udf(min(year)):string,Java_udf(sum(cast(earnings as bigint))):string,Java_udf(min(year)):string>
107+
struct<dotNET_CAST(udf(cast(sum(cast(earnings as bigint)) as string)) AS BIGINT):bigint,dotNET_CAST(udf(cast(min(year) as string)) AS INT):int,Java_CAST(udf(cast(sum(cast(earnings as bigint)) as string)) AS BIGINT):bigint,Java_CAST(udf(cast(min(year) as string)) AS INT):int>
108108
-- !query 7 output
109109
63000 2012 50000 2012
110110

@@ -120,12 +120,12 @@ PIVOT (
120120
FOR s IN (1, 2)
121121
)
122122
-- !query 8 schema
123-
struct<course:string,year:int,1:string,2:string>
123+
struct<course:string,year:int,1:bigint,2:bigint>
124124
-- !query 8 output
125-
Java 2012 20000 nan
126-
Java 2013 nan 30000
127-
dotNET 2012 15000 nan
128-
dotNET 2013 nan 48000
125+
Java 2012 20000 NULL
126+
Java 2013 NULL 30000
127+
dotNET 2012 15000 NULL
128+
dotNET 2013 NULL 48000
129129

130130

131131
-- !query 9
@@ -139,7 +139,7 @@ PIVOT (
139139
FOR course IN ('dotNET', 'Java')
140140
)
141141
-- !query 9 schema
142-
struct<year:int,dotNET_udf(sum(cast(earnings as bigint))):string,dotNET_udf(min(s)):string,Java_udf(sum(cast(earnings as bigint))):string,Java_udf(min(s)):string>
142+
struct<year:int,dotNET_CAST(udf(cast(sum(cast(earnings as bigint)) as string)) AS BIGINT):bigint,dotNET_CAST(udf(cast(min(s) as string)) AS INT):int,Java_CAST(udf(cast(sum(cast(earnings as bigint)) as string)) AS BIGINT):bigint,Java_CAST(udf(cast(min(s) as string)) AS INT):int>
143143
-- !query 9 output
144144
2012 15000 1 20000 1
145145
2013 48000 2 30000 2
@@ -156,7 +156,7 @@ PIVOT (
156156
FOR course IN ('dotNET', 'Java')
157157
)
158158
-- !query 10 schema
159-
struct<year:int,dotNET:string,Java:string>
159+
struct<year:int,dotNET:bigint,Java:bigint>
160160
-- !query 10 output
161161
2012 15000 20000
162162
2013 96000 60000
@@ -171,7 +171,7 @@ PIVOT (
171171
FOR y IN (2012, 2013)
172172
)
173173
-- !query 11 schema
174-
struct<2012_s:string,2013_s:string,2012_a:string,2013_a:string,c:string>
174+
struct<2012_s:bigint,2013_s:bigint,2012_a:double,2013_a:double,c:string>
175175
-- !query 11 output
176176
15000 48000 7500.0 48000.0 dotNET
177177
20000 30000 20000.0 30000.0 Java
@@ -186,7 +186,7 @@ PIVOT (
186186
FOR y IN (2012 as firstYear, 2013 secondYear)
187187
)
188188
-- !query 12 schema
189-
struct<firstYear_s:string,secondYear_s:string,firstYear_a:string,secondYear_a:string,c:string>
189+
struct<firstYear_s:bigint,secondYear_s:bigint,firstYear_a:double,secondYear_a:double,c:string>
190190
-- !query 12 output
191191
15000 48000 7500.0 48000.0 dotNET
192192
20000 30000 20000.0 30000.0 Java
@@ -244,7 +244,7 @@ PIVOT (
244244
FOR course IN ('dotNET', 'Java')
245245
)
246246
-- !query 16 schema
247-
struct<year:int,dotNET_udf(CEIL(cast(udf(sum(cast(earnings as bigint))) as double))):string,dotNET_a1:double,Java_udf(CEIL(cast(udf(sum(cast(earnings as bigint))) as double))):string,Java_a1:double>
247+
struct<year:int,dotNET_CAST(udf(cast(CEIL(cast(udf(cast(sum(cast(earnings as bigint)) as string)) as bigint)) as string)) AS BIGINT):bigint,dotNET_a1:double,Java_CAST(udf(cast(CEIL(cast(udf(cast(sum(cast(earnings as bigint)) as string)) as bigint)) as string)) AS BIGINT):bigint,Java_a1:double>
248248
-- !query 16 output
249249
2012 15000 7501.0 20000 20001.0
250250
2013 48000 48001.0 30000 30001.0
@@ -276,10 +276,10 @@ PIVOT (
276276
FOR (course, year) IN (('dotNET', 2012), ('Java', 2013))
277277
)
278278
-- !query 18 schema
279-
struct<s:int,[dotNET, 2012]:string,[Java, 2013]:string>
279+
struct<s:int,[dotNET, 2012]:bigint,[Java, 2013]:bigint>
280280
-- !query 18 output
281-
1 15000 nan
282-
2 nan 30000
281+
1 15000 NULL
282+
2 NULL 30000
283283

284284

285285
-- !query 19
@@ -293,10 +293,10 @@ PIVOT (
293293
FOR (course, s) IN (('dotNET', 2) as c1, ('Java', 1) as c2)
294294
)
295295
-- !query 19 schema
296-
struct<year:int,c1:string,c2:string>
296+
struct<year:int,c1:bigint,c2:bigint>
297297
-- !query 19 output
298-
2012 nan 20000
299-
2013 48000 nan
298+
2012 NULL 20000
299+
2013 48000 NULL
300300

301301

302302
-- !query 20
@@ -353,10 +353,10 @@ PIVOT (
353353
FOR a IN (array(1, 1), array(2, 2))
354354
)
355355
-- !query 23 schema
356-
struct<year:int,[1, 1]:string,[2, 2]:string>
356+
struct<year:int,[1, 1]:bigint,[2, 2]:bigint>
357357
-- !query 23 output
358-
2012 35000 nan
359-
2013 nan 78000
358+
2012 35000 NULL
359+
2013 NULL 78000
360360

361361

362362
-- !query 24
@@ -370,10 +370,10 @@ PIVOT (
370370
FOR (course, a) IN (('dotNET', array(1, 1)), ('Java', array(2, 2)))
371371
)
372372
-- !query 24 schema
373-
struct<year:int,[dotNET, [1, 1]]:string,[Java, [2, 2]]:string>
373+
struct<year:int,[dotNET, [1, 1]]:bigint,[Java, [2, 2]]:bigint>
374374
-- !query 24 output
375-
2012 15000 nan
376-
2013 nan 30000
375+
2012 15000 NULL
376+
2013 NULL 30000
377377

378378

379379
-- !query 25
@@ -387,10 +387,10 @@ PIVOT (
387387
FOR s IN ((1, 'a'), (2, 'b'))
388388
)
389389
-- !query 25 schema
390-
struct<year:int,[1, a]:string,[2, b]:string>
390+
struct<year:int,[1, a]:bigint,[2, b]:bigint>
391391
-- !query 25 output
392-
2012 35000 nan
393-
2013 nan 78000
392+
2012 35000 NULL
393+
2013 NULL 78000
394394

395395

396396
-- !query 26
@@ -404,10 +404,10 @@ PIVOT (
404404
FOR (course, s) IN (('dotNET', (1, 'a')), ('Java', (2, 'b')))
405405
)
406406
-- !query 26 schema
407-
struct<year:int,[dotNET, [1, a]]:string,[Java, [2, b]]:string>
407+
struct<year:int,[dotNET, [1, a]]:bigint,[Java, [2, b]]:bigint>
408408
-- !query 26 output
409-
2012 15000 nan
410-
2013 nan 30000
409+
2012 15000 NULL
410+
2013 NULL 30000
411411

412412

413413
-- !query 27
@@ -455,6 +455,6 @@ PIVOT (
455455
FOR Course IN ('dotNET', 'Java')
456456
)
457457
-- !query 29 schema
458-
struct<a:string,z:string,b:string,y:string,c:string,x:string,d:string,w:string,dotNET:string,Java:string>
458+
struct<a:string,z:string,b:string,y:string,c:string,x:string,d:string,w:string,dotNET:bigint,Java:bigint>
459459
-- !query 29 output
460460
a z b y c x d w 63000 50000

0 commit comments

Comments
 (0)