You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[SPARK-29863][SQL] Rename EveryAgg/AnyAgg to BoolAnd/BoolOr
### What changes were proposed in this pull request?
rename EveryAgg/AnyAgg to BoolAnd/BoolOr
### Why are the changes needed?
Under ansi mode, `every`, `any` and `some` are reserved keywords and can't be used as function names. `EveryAgg`/`AnyAgg` has several aliases and I think it's better to not pick reserved keywords as the primary name.
### Does this PR introduce any user-facing change?
no
### How was this patch tested?
existing tests
Closesapache#26486 from cloud-fan/naming.
Authored-by: Wenchen Fan <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
SELECT k, every(v) FROM test_agg GROUP BY k HAVING every(v) IS NULL
341
341
-- !query 36 schema
342
-
struct<k:int,every(v):boolean>
342
+
struct<k:int,bool_and(v):boolean>
343
343
-- !query 36 output
344
344
4 NULL
345
345
@@ -380,7 +380,7 @@ SELECT every(1)
380
380
struct<>
381
381
-- !query 39 output
382
382
org.apache.spark.sql.AnalysisException
383
-
cannot resolve 'every(1)' due to data type mismatch: Input to function 'every' should have been boolean, but it's [int].; line 1 pos 7
383
+
cannot resolve 'bool_and(1)' due to data type mismatch: Input to function 'bool_and' should have been boolean, but it's [int].; line 1 pos 7
384
384
385
385
386
386
-- !query 40
@@ -389,7 +389,7 @@ SELECT some(1S)
389
389
struct<>
390
390
-- !query 40 output
391
391
org.apache.spark.sql.AnalysisException
392
-
cannot resolve 'any(1S)' due to data type mismatch: Input to function 'any' should have been boolean, but it's [smallint].; line 1 pos 7
392
+
cannot resolve 'bool_or(1S)' due to data type mismatch: Input to function 'bool_or' should have been boolean, but it's [smallint].; line 1 pos 7
393
393
394
394
395
395
-- !query 41
@@ -398,7 +398,7 @@ SELECT any(1L)
398
398
struct<>
399
399
-- !query 41 output
400
400
org.apache.spark.sql.AnalysisException
401
-
cannot resolve 'any(1L)' due to data type mismatch: Input to function 'any' should have been boolean, but it's [bigint].; line 1 pos 7
401
+
cannot resolve 'bool_or(1L)' due to data type mismatch: Input to function 'bool_or' should have been boolean, but it's [bigint].; line 1 pos 7
402
402
403
403
404
404
-- !query 42
@@ -407,7 +407,7 @@ SELECT every("true")
407
407
struct<>
408
408
-- !query 42 output
409
409
org.apache.spark.sql.AnalysisException
410
-
cannot resolve 'every('true')' due to data type mismatch: Input to function 'every' should have been boolean, but it's [string].; line 1 pos 7
410
+
cannot resolve 'bool_and('true')' due to data type mismatch: Input to function 'bool_and' should have been boolean, but it's [string].; line 1 pos 7
411
411
412
412
413
413
-- !query 43
@@ -416,7 +416,7 @@ SELECT bool_and(1.0)
416
416
struct<>
417
417
-- !query 43 output
418
418
org.apache.spark.sql.AnalysisException
419
-
cannot resolve 'every(1.0BD)' due to data type mismatch: Input to function 'every' should have been boolean, but it's [decimal(2,1)].; line 1 pos 7
419
+
cannot resolve 'bool_and(1.0BD)' due to data type mismatch: Input to function 'bool_and' should have been boolean, but it's [decimal(2,1)].; line 1 pos 7
420
420
421
421
422
422
-- !query 44
@@ -425,13 +425,13 @@ SELECT bool_or(1.0D)
425
425
struct<>
426
426
-- !query 44 output
427
427
org.apache.spark.sql.AnalysisException
428
-
cannot resolve 'any(1.0D)' due to data type mismatch: Input to function 'any' should have been boolean, but it's [double].; line 1 pos 7
428
+
cannot resolve 'bool_or(1.0D)' due to data type mismatch: Input to function 'bool_or' should have been boolean, but it's [double].; line 1 pos 7
429
429
430
430
431
431
-- !query 45
432
432
SELECT k, v, every(v) OVER (PARTITION BY k ORDER BY v) FROM test_agg
433
433
-- !query 45 schema
434
-
struct<k:int,v:boolean,every(v) OVER (PARTITION BY k ORDER BY v ASC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW):boolean>
434
+
struct<k:int,v:boolean,bool_and(v) OVER (PARTITION BY k ORDER BY v ASC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW):boolean>
435
435
-- !query 45 output
436
436
1 false false
437
437
1 true false
@@ -448,7 +448,7 @@ struct<k:int,v:boolean,every(v) OVER (PARTITION BY k ORDER BY v ASC NULLS FIRST
448
448
-- !query 46
449
449
SELECT k, v, some(v) OVER (PARTITION BY k ORDER BY v) FROM test_agg
450
450
-- !query 46 schema
451
-
struct<k:int,v:boolean,any(v) OVER (PARTITION BY k ORDER BY v ASC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW):boolean>
451
+
struct<k:int,v:boolean,bool_or(v) OVER (PARTITION BY k ORDER BY v ASC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW):boolean>
452
452
-- !query 46 output
453
453
1 false false
454
454
1 true true
@@ -465,7 +465,7 @@ struct<k:int,v:boolean,any(v) OVER (PARTITION BY k ORDER BY v ASC NULLS FIRST RA
465
465
-- !query 47
466
466
SELECT k, v, any(v) OVER (PARTITION BY k ORDER BY v) FROM test_agg
467
467
-- !query 47 schema
468
-
struct<k:int,v:boolean,any(v) OVER (PARTITION BY k ORDER BY v ASC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW):boolean>
468
+
struct<k:int,v:boolean,bool_or(v) OVER (PARTITION BY k ORDER BY v ASC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW):boolean>
469
469
-- !query 47 output
470
470
1 false false
471
471
1 true true
@@ -482,7 +482,7 @@ struct<k:int,v:boolean,any(v) OVER (PARTITION BY k ORDER BY v ASC NULLS FIRST RA
482
482
-- !query 48
483
483
SELECT k, v, bool_and(v) OVER (PARTITION BY k ORDER BY v) FROM test_agg
484
484
-- !query 48 schema
485
-
struct<k:int,v:boolean,every(v) OVER (PARTITION BY k ORDER BY v ASC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW):boolean>
485
+
struct<k:int,v:boolean,bool_and(v) OVER (PARTITION BY k ORDER BY v ASC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW):boolean>
486
486
-- !query 48 output
487
487
1 false false
488
488
1 true false
@@ -499,7 +499,7 @@ struct<k:int,v:boolean,every(v) OVER (PARTITION BY k ORDER BY v ASC NULLS FIRST
499
499
-- !query 49
500
500
SELECT k, v, bool_or(v) OVER (PARTITION BY k ORDER BY v) FROM test_agg
501
501
-- !query 49 schema
502
-
struct<k:int,v:boolean,any(v) OVER (PARTITION BY k ORDER BY v ASC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW):boolean>
502
+
struct<k:int,v:boolean,bool_or(v) OVER (PARTITION BY k ORDER BY v ASC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW):boolean>
Copy file name to clipboardExpand all lines: sql/core/src/test/resources/sql-tests/results/udf/udf-group-by.sql.out
+13-13Lines changed: 13 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -293,31 +293,31 @@ struct<>
293
293
-- !query 31
294
294
SELECT udf(every(v)), udf(some(v)), any(v) FROM test_agg WHERE 1 = 0
295
295
-- !query 31 schema
296
-
struct<CAST(udf(cast(every(v) as string)) AS BOOLEAN):boolean,CAST(udf(cast(any(v) as string)) AS BOOLEAN):boolean,any(v):boolean>
296
+
struct<CAST(udf(cast(bool_and(v) as string)) AS BOOLEAN):boolean,CAST(udf(cast(bool_or(v) as string)) AS BOOLEAN):boolean,bool_or(v):boolean>
297
297
-- !query 31 output
298
298
NULL NULL NULL
299
299
300
300
301
301
-- !query 32
302
302
SELECT udf(every(udf(v))), some(v), any(v) FROM test_agg WHERE k = 4
303
303
-- !query 32 schema
304
-
struct<CAST(udf(cast(every(cast(udf(cast(v as string)) as boolean)) as string)) AS BOOLEAN):boolean,any(v):boolean,any(v):boolean>
304
+
struct<CAST(udf(cast(bool_and(cast(udf(cast(v as string)) as boolean)) as string)) AS BOOLEAN):boolean,bool_or(v):boolean,bool_or(v):boolean>
305
305
-- !query 32 output
306
306
NULL NULL NULL
307
307
308
308
309
309
-- !query 33
310
310
SELECT every(v), udf(some(v)), any(v) FROM test_agg WHERE k = 5
311
311
-- !query 33 schema
312
-
struct<every(v):boolean,CAST(udf(cast(any(v) as string)) AS BOOLEAN):boolean,any(v):boolean>
312
+
struct<bool_and(v):boolean,CAST(udf(cast(bool_or(v) as string)) AS BOOLEAN):boolean,bool_or(v):boolean>
313
313
-- !query 33 output
314
314
false true true
315
315
316
316
317
317
-- !query 34
318
318
SELECT udf(k), every(v), udf(some(v)), any(v) FROM test_agg GROUP BY udf(k)
319
319
-- !query 34 schema
320
-
struct<CAST(udf(cast(k as string)) AS INT):int,every(v):boolean,CAST(udf(cast(any(v) as string)) AS BOOLEAN):boolean,any(v):boolean>
320
+
struct<CAST(udf(cast(k as string)) AS INT):int,bool_and(v):boolean,CAST(udf(cast(bool_or(v) as string)) AS BOOLEAN):boolean,bool_or(v):boolean>
321
321
-- !query 34 output
322
322
1 false true true
323
323
2 true true true
@@ -329,7 +329,7 @@ struct<CAST(udf(cast(k as string)) AS INT):int,every(v):boolean,CAST(udf(cast(an
329
329
-- !query 35
330
330
SELECT udf(k), every(v) FROM test_agg GROUP BY k HAVING every(v) = false
331
331
-- !query 35 schema
332
-
struct<CAST(udf(cast(k as string)) AS INT):int,every(v):boolean>
332
+
struct<CAST(udf(cast(k as string)) AS INT):int,bool_and(v):boolean>
333
333
-- !query 35 output
334
334
1 false
335
335
3 false
@@ -339,7 +339,7 @@ struct<CAST(udf(cast(k as string)) AS INT):int,every(v):boolean>
339
339
-- !query 36
340
340
SELECT udf(k), udf(every(v)) FROM test_agg GROUP BY udf(k) HAVING every(v) IS NULL
341
341
-- !query 36 schema
342
-
struct<CAST(udf(cast(k as string)) AS INT):int,CAST(udf(cast(every(v) as string)) AS BOOLEAN):boolean>
342
+
struct<CAST(udf(cast(k as string)) AS INT):int,CAST(udf(cast(bool_and(v) as string)) AS BOOLEAN):boolean>
343
343
-- !query 36 output
344
344
4 NULL
345
345
@@ -380,7 +380,7 @@ SELECT every(udf(1))
380
380
struct<>
381
381
-- !query 39 output
382
382
org.apache.spark.sql.AnalysisException
383
-
cannot resolve 'every(CAST(udf(cast(1 as string)) AS INT))' due to data type mismatch: Input to function 'every' should have been boolean, but it's [int].; line 1 pos 7
383
+
cannot resolve 'bool_and(CAST(udf(cast(1 as string)) AS INT))' due to data type mismatch: Input to function 'bool_and' should have been boolean, but it's [int].; line 1 pos 7
384
384
385
385
386
386
-- !query 40
@@ -389,7 +389,7 @@ SELECT some(udf(1S))
389
389
struct<>
390
390
-- !query 40 output
391
391
org.apache.spark.sql.AnalysisException
392
-
cannot resolve 'any(CAST(udf(cast(1 as string)) AS SMALLINT))' due to data type mismatch: Input to function 'any' should have been boolean, but it's [smallint].; line 1 pos 7
392
+
cannot resolve 'bool_or(CAST(udf(cast(1 as string)) AS SMALLINT))' due to data type mismatch: Input to function 'bool_or' should have been boolean, but it's [smallint].; line 1 pos 7
393
393
394
394
395
395
-- !query 41
@@ -398,7 +398,7 @@ SELECT any(udf(1L))
398
398
struct<>
399
399
-- !query 41 output
400
400
org.apache.spark.sql.AnalysisException
401
-
cannot resolve 'any(CAST(udf(cast(1 as string)) AS BIGINT))' due to data type mismatch: Input to function 'any' should have been boolean, but it's [bigint].; line 1 pos 7
401
+
cannot resolve 'bool_or(CAST(udf(cast(1 as string)) AS BIGINT))' due to data type mismatch: Input to function 'bool_or' should have been boolean, but it's [bigint].; line 1 pos 7
402
402
403
403
404
404
-- !query 42
@@ -407,13 +407,13 @@ SELECT udf(every("true"))
407
407
struct<>
408
408
-- !query 42 output
409
409
org.apache.spark.sql.AnalysisException
410
-
cannot resolve 'every('true')' due to data type mismatch: Input to function 'every' should have been boolean, but it's [string].; line 1 pos 11
410
+
cannot resolve 'bool_and('true')' due to data type mismatch: Input to function 'bool_and' should have been boolean, but it's [string].; line 1 pos 11
411
411
412
412
413
413
-- !query 43
414
414
SELECT k, v, every(v) OVER (PARTITION BY k ORDER BY v) FROM test_agg
415
415
-- !query 43 schema
416
-
struct<k:int,v:boolean,every(v) OVER (PARTITION BY k ORDER BY v ASC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW):boolean>
416
+
struct<k:int,v:boolean,bool_and(v) OVER (PARTITION BY k ORDER BY v ASC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW):boolean>
417
417
-- !query 43 output
418
418
1 false false
419
419
1 true false
@@ -430,7 +430,7 @@ struct<k:int,v:boolean,every(v) OVER (PARTITION BY k ORDER BY v ASC NULLS FIRST
430
430
-- !query 44
431
431
SELECT k, udf(udf(v)), some(v) OVER (PARTITION BY k ORDER BY v) FROM test_agg
432
432
-- !query 44 schema
433
-
struct<k:int,CAST(udf(cast(cast(udf(cast(v as string)) as boolean) as string)) AS BOOLEAN):boolean,any(v) OVER (PARTITION BY k ORDER BY v ASC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW):boolean>
433
+
struct<k:int,CAST(udf(cast(cast(udf(cast(v as string)) as boolean) as string)) AS BOOLEAN):boolean,bool_or(v) OVER (PARTITION BY k ORDER BY v ASC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW):boolean>
434
434
-- !query 44 output
435
435
1 false false
436
436
1 true true
@@ -447,7 +447,7 @@ struct<k:int,CAST(udf(cast(cast(udf(cast(v as string)) as boolean) as string)) A
447
447
-- !query 45
448
448
SELECT udf(udf(k)), v, any(v) OVER (PARTITION BY k ORDER BY v) FROM test_agg
449
449
-- !query 45 schema
450
-
struct<CAST(udf(cast(cast(udf(cast(k as string)) as int) as string)) AS INT):int,v:boolean,any(v) OVER (PARTITION BY k ORDER BY v ASC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW):boolean>
450
+
struct<CAST(udf(cast(cast(udf(cast(k as string)) as int) as string)) AS INT):int,v:boolean,bool_or(v) OVER (PARTITION BY k ORDER BY v ASC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW):boolean>
0 commit comments