-
Notifications
You must be signed in to change notification settings - Fork 453
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[VL] Support Spark assert_true function (#6329)
- Loading branch information
1 parent
0448115
commit 6f189c7
Showing
25 changed files
with
1,062 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
gluten-ut/spark32/src/test/resources/sql-tests/inputs/misc-functions.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-- test for misc functions | ||
|
||
-- typeof | ||
select typeof(null); | ||
select typeof(true); | ||
select typeof(1Y), typeof(1S), typeof(1), typeof(1L); | ||
select typeof(cast(1.0 as float)), typeof(1.0D), typeof(1.2); | ||
select typeof(date '1986-05-23'), typeof(timestamp '1986-05-23'), typeof(interval '23 days'); | ||
select typeof(x'ABCD'), typeof('SPARK'); | ||
select typeof(array(1, 2)), typeof(map(1, 2)), typeof(named_struct('a', 1, 'b', 'spark')); | ||
|
||
-- Spark-32793: Rewrite AssertTrue with RaiseError | ||
SELECT assert_true(true), assert_true(boolean(1)); | ||
SELECT assert_true(false); | ||
SELECT assert_true(boolean(0)); | ||
SELECT assert_true(null); | ||
SELECT assert_true(boolean(null)); | ||
SELECT assert_true(false, 'custom error message'); | ||
|
||
CREATE TEMPORARY VIEW tbl_misc AS SELECT * FROM (VALUES (1), (8), (2)) AS T(v); | ||
SELECT raise_error('error message'); | ||
SELECT if(v > 5, raise_error('too big: ' || v), v + 1) FROM tbl_misc; |
137 changes: 137 additions & 0 deletions
137
gluten-ut/spark32/src/test/resources/sql-tests/results/misc-functions.sql.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
-- Automatically generated by SQLQueryTestSuite | ||
-- Number of queries: 16 | ||
|
||
|
||
-- !query | ||
select typeof(null) | ||
-- !query schema | ||
struct<typeof(NULL):string> | ||
-- !query output | ||
void | ||
|
||
|
||
-- !query | ||
select typeof(true) | ||
-- !query schema | ||
struct<typeof(true):string> | ||
-- !query output | ||
boolean | ||
|
||
|
||
-- !query | ||
select typeof(1Y), typeof(1S), typeof(1), typeof(1L) | ||
-- !query schema | ||
struct<typeof(1):string,typeof(1):string,typeof(1):string,typeof(1):string> | ||
-- !query output | ||
tinyint smallint int bigint | ||
|
||
|
||
-- !query | ||
select typeof(cast(1.0 as float)), typeof(1.0D), typeof(1.2) | ||
-- !query schema | ||
struct<typeof(CAST(1.0 AS FLOAT)):string,typeof(1.0):string,typeof(1.2):string> | ||
-- !query output | ||
float double decimal(2,1) | ||
|
||
|
||
-- !query | ||
select typeof(date '1986-05-23'), typeof(timestamp '1986-05-23'), typeof(interval '23 days') | ||
-- !query schema | ||
struct<typeof(DATE '1986-05-23'):string,typeof(TIMESTAMP '1986-05-23 00:00:00'):string,typeof(INTERVAL '23' DAY):string> | ||
-- !query output | ||
date timestamp interval day | ||
|
||
|
||
-- !query | ||
select typeof(x'ABCD'), typeof('SPARK') | ||
-- !query schema | ||
struct<typeof(X'ABCD'):string,typeof(SPARK):string> | ||
-- !query output | ||
binary string | ||
|
||
|
||
-- !query | ||
select typeof(array(1, 2)), typeof(map(1, 2)), typeof(named_struct('a', 1, 'b', 'spark')) | ||
-- !query schema | ||
struct<typeof(array(1, 2)):string,typeof(map(1, 2)):string,typeof(named_struct(a, 1, b, spark)):string> | ||
-- !query output | ||
array<int> map<int,int> struct<a:int,b:string> | ||
|
||
|
||
-- !query | ||
SELECT assert_true(true), assert_true(boolean(1)) | ||
-- !query schema | ||
struct<assert_true(true, 'true' is not true!):void,assert_true(1, 'cast(1 as boolean)' is not true!):void> | ||
-- !query output | ||
NULL NULL | ||
|
||
|
||
-- !query | ||
SELECT assert_true(false) | ||
-- !query schema | ||
struct<> | ||
-- !query output | ||
org.apache.gluten.exception.GlutenException | ||
'false' is not true! | ||
|
||
|
||
-- !query | ||
SELECT assert_true(boolean(0)) | ||
-- !query schema | ||
struct<> | ||
-- !query output | ||
org.apache.gluten.exception.GlutenException | ||
'cast(0 as boolean)' is not true! | ||
|
||
|
||
-- !query | ||
SELECT assert_true(null) | ||
-- !query schema | ||
struct<> | ||
-- !query output | ||
org.apache.gluten.exception.GlutenException | ||
'null' is not true! | ||
|
||
|
||
-- !query | ||
SELECT assert_true(boolean(null)) | ||
-- !query schema | ||
struct<> | ||
-- !query output | ||
org.apache.gluten.exception.GlutenException | ||
'cast(null as boolean)' is not true! | ||
|
||
|
||
-- !query | ||
SELECT assert_true(false, 'custom error message') | ||
-- !query schema | ||
struct<> | ||
-- !query output | ||
org.apache.gluten.exception.GlutenException | ||
custom error message | ||
|
||
|
||
-- !query | ||
CREATE TEMPORARY VIEW tbl_misc AS SELECT * FROM (VALUES (1), (8), (2)) AS T(v) | ||
-- !query schema | ||
struct<> | ||
-- !query output | ||
|
||
|
||
|
||
-- !query | ||
SELECT raise_error('error message') | ||
-- !query schema | ||
struct<> | ||
-- !query output | ||
org.apache.gluten.exception.GlutenException | ||
error message | ||
|
||
|
||
-- !query | ||
SELECT if(v > 5, raise_error('too big: ' || v), v + 1) FROM tbl_misc | ||
-- !query schema | ||
struct<> | ||
-- !query output | ||
org.apache.gluten.exception.GlutenException | ||
too big: 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
gluten-ut/spark33/src/test/resources/sql-tests/inputs/misc-functions.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-- test for misc functions | ||
|
||
-- typeof | ||
select typeof(null); | ||
select typeof(true); | ||
select typeof(1Y), typeof(1S), typeof(1), typeof(1L); | ||
select typeof(cast(1.0 as float)), typeof(1.0D), typeof(1.2); | ||
select typeof(date '1986-05-23'), typeof(timestamp '1986-05-23'), typeof(interval '23 days'); | ||
select typeof(x'ABCD'), typeof('SPARK'); | ||
select typeof(array(1, 2)), typeof(map(1, 2)), typeof(named_struct('a', 1, 'b', 'spark')); | ||
|
||
-- Spark-32793: Rewrite AssertTrue with RaiseError | ||
SELECT assert_true(true), assert_true(boolean(1)); | ||
SELECT assert_true(false); | ||
SELECT assert_true(boolean(0)); | ||
SELECT assert_true(null); | ||
SELECT assert_true(boolean(null)); | ||
SELECT assert_true(false, 'custom error message'); | ||
|
||
CREATE TEMPORARY VIEW tbl_misc AS SELECT * FROM (VALUES (1), (8), (2)) AS T(v); | ||
SELECT raise_error('error message'); | ||
SELECT if(v > 5, raise_error('too big: ' || v), v + 1) FROM tbl_misc; |
Oops, something went wrong.