Skip to content

Commit

Permalink
[SPARK-28227][SQL][FOLLOWUP] Add test case about transform with distict
Browse files Browse the repository at this point in the history
  • Loading branch information
AngersZhuuuu committed Apr 13, 2021
1 parent b34a84e commit 118f242
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
9 changes: 7 additions & 2 deletions sql/core/src/test/resources/sql-tests/inputs/transform.sql
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ SET spark.sql.legacy.parser.havingWithoutGroupByAsWhere=false;
SET spark.sql.parser.quotedRegexColumnNames=true;

SELECT TRANSFORM(`(a|b)?+.+`)
USING 'cat' AS (c)
USING 'cat' AS (c)
FROM script_trans;

SET spark.sql.parser.quotedRegexColumnNames=false;
Expand All @@ -320,4 +320,9 @@ SET spark.sql.parser.quotedRegexColumnNames=false;
WITH temp AS (
SELECT TRANSFORM(a) USING 'cat' AS (b string) FROM t
)
SELECT t1.b FROM temp t1 JOIN temp t2 ON t1.b = t2.b
SELECT t1.b FROM temp t1 JOIN temp t2 ON t1.b = t2.b;

SELECT TRANSFORM(distinct b, a, c)
USING 'cat' AS (a, b, c)
FROM script_trans
WHERE a <= 4;
17 changes: 15 additions & 2 deletions sql/core/src/test/resources/sql-tests/results/transform.sql.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Automatically generated by SQLQueryTestSuite
-- Number of queries: 42
-- Number of queries: 43


-- !query
Expand Down Expand Up @@ -610,7 +610,7 @@ spark.sql.parser.quotedRegexColumnNames true

-- !query
SELECT TRANSFORM(`(a|b)?+.+`)
USING 'cat' AS (c)
USING 'cat' AS (c)
FROM script_trans
-- !query schema
struct<c:string>
Expand All @@ -627,6 +627,7 @@ struct<key:string,value:string>
-- !query output
spark.sql.parser.quotedRegexColumnNames false


-- !query
WITH temp AS (
SELECT TRANSFORM(a) USING 'cat' AS (b string) FROM t
Expand All @@ -638,3 +639,15 @@ struct<b:string>
1
2
3


-- !query
SELECT TRANSFORM(distinct b, a, c)
USING 'cat' AS (a, b, c)
FROM script_trans
WHERE a <= 4
-- !query schema
struct<>
-- !query output
org.apache.spark.sql.AnalysisException
cannot resolve 'distinct' given input columns: [script_trans.a, script_trans.b, script_trans.c]; line 1 pos 17

0 comments on commit 118f242

Please sign in to comment.