Skip to content

Commit d205a13

Browse files
committed
Fix
1 parent 303b8c8 commit d205a13

File tree

3 files changed

+23
-33
lines changed

3 files changed

+23
-33
lines changed

sql/core/src/test/resources/sql-tests/inputs/transform.sql

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,6 @@ SELECT TRANSFORM(a)
99
USING 'cat' AS (a)
1010
FROM t;
1111

12-
-- with non-exist command
13-
SELECT TRANSFORM(a)
14-
USING 'some_non_existent_command' AS (a)
15-
FROM t;
16-
17-
-- with non-exist file
18-
SELECT TRANSFORM(a)
19-
USING 'python some_non_existent_file' AS (a)
20-
FROM t;
21-
2212
-- common supported data types between no serde and serde transform
2313
SELECT a, b, decode(c, 'UTF-8'), d, e, f, g, h, i, j, k, l FROM (
2414
SELECT TRANSFORM(a, b, c, d, e, f, g, h, i, j, k, l)

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

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Automatically generated by SQLQueryTestSuite
2-
-- Number of queries: 18
2+
-- Number of queries: 16
33

44

55
-- !query
@@ -26,28 +26,6 @@ struct<a:string>
2626
3
2727

2828

29-
-- !query
30-
SELECT TRANSFORM(a)
31-
USING 'some_non_existent_command' AS (a)
32-
FROM t
33-
-- !query schema
34-
struct<>
35-
-- !query output
36-
org.apache.spark.SparkException
37-
Subprocess exited with status 127. Error: /bin/bash: some_non_existent_command: command not found
38-
39-
40-
-- !query
41-
SELECT TRANSFORM(a)
42-
USING 'python some_non_existent_file' AS (a)
43-
FROM t
44-
-- !query schema
45-
struct<>
46-
-- !query output
47-
org.apache.spark.SparkException
48-
Subprocess exited with status 2. Error: python: can't open file 'some_non_existent_file': [Errno 2] No such file or directory
49-
50-
5129
-- !query
5230
SELECT a, b, decode(c, 'UTF-8'), d, e, f, g, h, i, j, k, l FROM (
5331
SELECT TRANSFORM(a, b, c, d, e, f, g, h, i, j, k, l)

sql/core/src/test/scala/org/apache/spark/sql/execution/BaseScriptTransformationSuite.scala

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,28 @@ abstract class BaseScriptTransformationSuite extends SparkPlanTest with SQLTestU
420420
'b.cast("string").as("b"),
421421
lit(null), lit(null)).collect())
422422
}
423+
424+
test("SPARK-32106: TRANSFORM with non-existent command/file") {
425+
val e1 = intercept[SparkException] {
426+
sql(
427+
"""
428+
|SELECT TRANSFORM(a)
429+
|USING 'some_non_existent_command' AS (a)
430+
|FROM VALUES (1) t(a)
431+
""".stripMargin).collect()
432+
}.getMessage
433+
assert(e1.contains("Subprocess exited"))
434+
435+
val e2 = intercept[SparkException] {
436+
sql(
437+
"""
438+
|SELECT TRANSFORM(a)
439+
|USING 'python some_non_existent_file' AS (a)
440+
|FROM VALUES (1) t(a)
441+
""".stripMargin).collect()
442+
}.getMessage
443+
assert(e2.contains("Subprocess exited"))
444+
}
423445
}
424446

425447
case class ExceptionInjectingOperator(child: SparkPlan) extends UnaryExecNode {

0 commit comments

Comments
 (0)