Skip to content

Commit 3ae7811

Browse files
committed
fix SQLQueryTestSuite for the revert, mainly related with int div int
1 parent a6b1f73 commit 3ae7811

8 files changed

Lines changed: 79 additions & 59 deletions

File tree

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

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ struct<datediff(DATE '2001-10-01', DATE '2001-09-28'):int>
134134
-- !query 15
135135
select date'2020-01-01' - timestamp'2019-10-06 10:11:12.345678'
136136
-- !query 15 schema
137-
struct<timestampdiff(CAST(DATE '2020-01-01' AS TIMESTAMP), TIMESTAMP('2019-10-06 10:11:12.345678')):interval>
137+
struct<timestampdiff(CAST(DATE '2020-01-01' AS TIMESTAMP), TIMESTAMP '2019-10-06 10:11:12.345678'):interval>
138138
-- !query 15 output
139139
2078 hours 48 minutes 47.654322 seconds
140140

sql/core/src/test/resources/sql-tests/results/postgreSQL/int4.sql.out

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ SELECT '' AS five, i.f1, i.f1 / smallint('2') AS x FROM INT4_TBL i
323323
-- !query 33 schema
324324
struct<five:string,f1:int,x:double>
325325
-- !query 33 output
326-
-123456 -61728.0
326+
-123456 -61728.0
327327
-2147483647 -1.0737418235E9
328328
0 0.0
329329
123456 61728.0
@@ -335,7 +335,7 @@ SELECT '' AS five, i.f1, i.f1 / int('2') AS x FROM INT4_TBL i
335335
-- !query 34 schema
336336
struct<five:string,f1:int,x:double>
337337
-- !query 34 output
338-
-123456 -61728.0
338+
-123456 -61728.0
339339
-2147483647 -1.0737418235E9
340340
0 0.0
341341
123456 61728.0

sql/core/src/test/resources/sql-tests/results/postgreSQL/int8.sql.out

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ SELECT '' AS five, q1, q2, q1 / q2 AS divide, q1 % q2 AS mod FROM INT8_TBL
411411
-- !query 42 schema
412412
struct<five:string,q1:bigint,q2:bigint,divide:double,mod:bigint>
413413
-- !query 42 output
414-
123 456 0.26973684210526316 123
414+
123 456 0.26973684210526316 123
415415
123 4567890123456789 2.6927092525360204E-14 123
416416
4567890123456789 -4567890123456789 -1.0 0
417417
4567890123456789 123 3.713731807688446E13 57

sql/core/src/test/resources/sql-tests/results/postgreSQL/select_implicit.sql.out

100644100755
Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -239,31 +239,36 @@ struct<a:int,a:int>
239239
SELECT a/2, a/2 FROM test_missing_target
240240
ORDER BY a/2
241241
-- !query 23 schema
242-
struct<(a div 2):int,(a div 2):int>
242+
struct<(CAST(a AS DOUBLE) / CAST(2 AS DOUBLE)):double,(CAST(a AS DOUBLE) / CAST(2 AS DOUBLE)):double>
243243
-- !query 23 output
244-
0 0
245-
0 0
246-
1 1
247-
1 1
248-
2 2
249-
2 2
250-
3 3
251-
3 3
252-
4 4
253-
4 4
244+
0.0 0.0
245+
0.5 0.5
246+
1.0 1.0
247+
1.5 1.5
248+
2.0 2.0
249+
2.5 2.5
250+
3.0 3.0
251+
3.5 3.5
252+
4.0 4.0
253+
4.5 4.5
254254

255255

256256
-- !query 24
257257
SELECT a/2, a/2 FROM test_missing_target
258258
GROUP BY a/2 ORDER BY a/2
259259
-- !query 24 schema
260-
struct<(a div 2):int,(a div 2):int>
260+
struct<(CAST(a AS DOUBLE) / CAST(2 AS DOUBLE)):double,(CAST(a AS DOUBLE) / CAST(2 AS DOUBLE)):double>
261261
-- !query 24 output
262-
0 0
263-
1 1
264-
2 2
265-
3 3
266-
4 4
262+
0.0 0.0
263+
0.5 0.5
264+
1.0 1.0
265+
1.5 1.5
266+
2.0 2.0
267+
2.5 2.5
268+
3.0 3.0
269+
3.5 3.5
270+
4.0 4.0
271+
4.5 4.5
267272

268273

269274
-- !query 25
@@ -331,7 +336,8 @@ SELECT count(b) FROM test_missing_target GROUP BY b/2 ORDER BY b/2
331336
struct<count(b):bigint>
332337
-- !query 30 output
333338
1
334-
5
339+
2
340+
3
335341
4
336342

337343

@@ -370,8 +376,10 @@ SELECT count(b) FROM test_missing_target
370376
-- !query 33 schema
371377
struct<count(b):bigint>
372378
-- !query 33 output
373-
7
379+
4
374380
3
381+
2
382+
1
375383

376384

377385
-- !query 34
@@ -390,11 +398,12 @@ SELECT x.b/2, count(x.b) FROM test_missing_target x, test_missing_target y
390398
WHERE x.a = y.a
391399
GROUP BY x.b/2 ORDER BY x.b/2
392400
-- !query 35 schema
393-
struct<(b div 2):int,count(b):bigint>
401+
struct<(CAST(b AS DOUBLE) / CAST(2 AS DOUBLE)):double,count(b):bigint>
394402
-- !query 35 output
395-
0 1
396-
1 5
397-
2 4
403+
0.5 1
404+
1.0 2
405+
1.5 3
406+
2.0 4
398407

399408

400409
-- !query 36

sql/core/src/test/resources/sql-tests/results/postgreSQL/window_part1.sql.out

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ struct<total:bigint,fourcount:bigint,twosum:bigint>
387387
-- !query 23
388388
SELECT avg(four) OVER (PARTITION BY four ORDER BY thousand / 100) FROM tenk1 WHERE unique2 < 10
389389
-- !query 23 schema
390-
struct<avg(CAST(four AS BIGINT)) OVER (PARTITION BY four ORDER BY (thousand div 100) ASC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW):double>
390+
struct<avg(CAST(four AS BIGINT)) OVER (PARTITION BY four ORDER BY (CAST(thousand AS DOUBLE) / CAST(100 AS DOUBLE)) ASC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW):double>
391391
-- !query 23 output
392392
0.0
393393
0.0

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

100644100755
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,28 +176,28 @@ struct<None:string,NULL on no matches:int>
176176
-- !query 18
177177
SELECT CASE WHEN udf(1=0) THEN 1/0 WHEN 1=1 THEN 1 ELSE 2/0 END
178178
-- !query 18 schema
179-
struct<CASE WHEN CAST(udf((1 = 0)) AS BOOLEAN) THEN (CAST(1 AS DOUBLE) / CAST(0 AS DOUBLE)) WHEN (1 = 1) THEN CAST(1 AS DOUBLE) ELSE (CAST(2 AS DOUBLE) / CAST(0 AS DOUBLE)) END:double>
179+
struct<CASE WHEN CAST(udf(cast((1 = 0) as string)) AS BOOLEAN) THEN (CAST(1 AS DOUBLE) / CAST(0 AS DOUBLE)) WHEN (1 = 1) THEN CAST(1 AS DOUBLE) ELSE (CAST(2 AS DOUBLE) / CAST(0 AS DOUBLE)) END:double>
180180
-- !query 18 output
181181
1.0
182182

183183

184184
-- !query 19
185185
SELECT CASE 1 WHEN 0 THEN 1/udf(0) WHEN 1 THEN 1 ELSE 2/0 END
186186
-- !query 19 schema
187-
struct<CASE WHEN (1 = 0) THEN (CAST(1 AS DOUBLE) / CAST(CAST(udf(0) AS DOUBLE) AS DOUBLE)) WHEN (1 = 1) THEN CAST(1 AS DOUBLE) ELSE (CAST(2 AS DOUBLE) / CAST(0 AS DOUBLE)) END:double>
187+
struct<CASE WHEN (1 = 0) THEN (CAST(1 AS DOUBLE) / CAST(CAST(udf(cast(0 as string)) AS INT) AS DOUBLE)) WHEN (1 = 1) THEN CAST(1 AS DOUBLE) ELSE (CAST(2 AS DOUBLE) / CAST(0 AS DOUBLE)) END:double>
188188
-- !query 19 output
189-
1
189+
1.0
190190

191191

192192
-- !query 20
193193
SELECT CASE WHEN i > 100 THEN udf(1/0) ELSE udf(0) END FROM case_tbl
194194
-- !query 20 schema
195-
struct<CASE WHEN (i > 100) THEN udf((cast(1 as double) / cast(0 as double))) ELSE udf(0) END:string>
195+
struct<CASE WHEN (i > 100) THEN CAST(udf(cast((cast(1 as double) / cast(0 as double)) as string)) AS DOUBLE) ELSE CAST(CAST(udf(cast(0 as string)) AS INT) AS DOUBLE) END:double>
196196
-- !query 20 output
197-
0
198-
0
199-
0
200-
0
197+
0.0
198+
0.0
199+
0.0
200+
0.0
201201

202202

203203
-- !query 21

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

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -242,31 +242,36 @@ struct<CAST(udf(cast(a as string)) AS INT):int,CAST(udf(cast(a as string)) AS IN
242242
SELECT udf(udf(a)/2), udf(udf(a)/2) FROM test_missing_target
243243
ORDER BY udf(udf(a)/2)
244244
-- !query 23 schema
245-
struct<CAST(udf(cast((cast(udf(cast(a as string)) as int) div 2) as string)) AS INT):int,CAST(udf(cast((cast(udf(cast(a as string)) as int) div 2) as string)) AS INT):int>
245+
struct<CAST(udf(cast((cast(cast(udf(cast(a as string)) as int) as double) / cast(2 as double)) as string)) AS DOUBLE):double,CAST(udf(cast((cast(cast(udf(cast(a as string)) as int) as double) / cast(2 as double)) as string)) AS DOUBLE):double>
246246
-- !query 23 output
247-
0 0
248-
0 0
249-
1 1
250-
1 1
251-
2 2
252-
2 2
253-
3 3
254-
3 3
255-
4 4
256-
4 4
247+
0.0 0.0
248+
0.5 0.5
249+
1.0 1.0
250+
1.5 1.5
251+
2.0 2.0
252+
2.5 2.5
253+
3.0 3.0
254+
3.5 3.5
255+
4.0 4.0
256+
4.5 4.5
257257

258258

259259
-- !query 24
260260
SELECT udf(a/2), udf(a/2) FROM test_missing_target
261261
GROUP BY udf(a/2) ORDER BY udf(a/2)
262262
-- !query 24 schema
263-
struct<CAST(udf(cast((a div 2) as string)) AS INT):int,CAST(udf(cast((a div 2) as string)) AS INT):int>
263+
struct<CAST(udf(cast((cast(a as double) / cast(2 as double)) as string)) AS DOUBLE):double,CAST(udf(cast((cast(a as double) / cast(2 as double)) as string)) AS DOUBLE):double>
264264
-- !query 24 output
265-
0 0
266-
1 1
267-
2 2
268-
3 3
269-
4 4
265+
0.0 0.0
266+
0.5 0.5
267+
1.0 1.0
268+
1.5 1.5
269+
2.0 2.0
270+
2.5 2.5
271+
3.0 3.0
272+
3.5 3.5
273+
4.0 4.0
274+
4.5 4.5
270275

271276

272277
-- !query 25
@@ -334,7 +339,8 @@ SELECT udf(count(b)) FROM test_missing_target GROUP BY udf(b/2) ORDER BY udf(b/2
334339
struct<CAST(udf(cast(count(b) as string)) AS BIGINT):bigint>
335340
-- !query 30 output
336341
1
337-
5
342+
2
343+
3
338344
4
339345

340346

@@ -373,8 +379,10 @@ SELECT udf(count(b)) FROM test_missing_target
373379
-- !query 33 schema
374380
struct<CAST(udf(cast(count(b) as string)) AS BIGINT):bigint>
375381
-- !query 33 output
376-
7
382+
4
377383
3
384+
2
385+
1
378386

379387

380388
-- !query 34
@@ -394,11 +402,12 @@ test_missing_target y
394402
WHERE udf(x.a) = udf(y.a)
395403
GROUP BY udf(x.b/2) ORDER BY udf(x.b/2)
396404
-- !query 35 schema
397-
struct<CAST(udf(cast((b div 2) as string)) AS INT):int,CAST(udf(cast(count(cast(udf(cast(b as string)) as int)) as string)) AS BIGINT):bigint>
405+
struct<CAST(udf(cast((cast(b as double) / cast(2 as double)) as string)) AS DOUBLE):double,CAST(udf(cast(count(cast(udf(cast(b as string)) as int)) as string)) AS BIGINT):bigint>
398406
-- !query 35 output
399-
0 1
400-
1 5
401-
2 4
407+
0.5 1
408+
1.0 2
409+
1.5 3
410+
2.0 4
402411

403412

404413
-- !query 36

sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,8 @@ class SQLQueryTestSuite extends QueryTest with SharedSparkSession {
333333
// vol used by boolean.sql and case.sql.
334334
localSparkSession.udf.register("vol", (s: String) => s)
335335
localSparkSession.conf.set(SQLConf.ANSI_ENABLED.key, true)
336+
case _: AnsiTest =>
337+
localSparkSession.conf.set(SQLConf.ANSI_ENABLED.key, true)
336338
case _ =>
337339
}
338340

0 commit comments

Comments
 (0)