|
17 | 17 |
|
18 | 18 | package org.apache.spark.sql.execution |
19 | 19 |
|
20 | | -import org.apache.spark.TestUtils |
| 20 | +import org.apache.spark.{SparkException, TestUtils} |
21 | 21 | import org.apache.spark.sql.catalyst.expressions.{Attribute, Expression} |
22 | 22 | import org.apache.spark.sql.catalyst.parser.ParseException |
23 | 23 | import org.apache.spark.sql.test.SharedSparkSession |
@@ -61,4 +61,43 @@ class SparkScriptTransformationSuite extends BaseScriptTransformationSuite with |
61 | 61 | assert(e.contains("TRANSFORM with serde is only supported in hive mode")) |
62 | 62 | } |
63 | 63 | } |
| 64 | + |
| 65 | + test("TRANSFORM don't support ArrayType/MapType/StructType as output data type (no serde)") { |
| 66 | + assume(TestUtils.testCommandAvailable("/bin/bash")) |
| 67 | + // check for ArrayType |
| 68 | + val e1 = intercept[SparkException] { |
| 69 | + sql( |
| 70 | + """ |
| 71 | + |SELECT TRANSFORM(a) |
| 72 | + |USING 'cat' AS (a array<int>) |
| 73 | + |FROM VALUES (array(1, 1), map('1', 1), struct(1, 'a')) t(a, b, c) |
| 74 | + """.stripMargin).collect() |
| 75 | + }.getMessage |
| 76 | + assert(e1.contains("TRANSFORM without serde don't support" + |
| 77 | + " ArrayType/MapType/StructType as output data type")) |
| 78 | + |
| 79 | + // check for MapType |
| 80 | + val e2 = intercept[SparkException] { |
| 81 | + sql( |
| 82 | + """ |
| 83 | + |SELECT TRANSFORM(b) |
| 84 | + |USING 'cat' AS (b map<int, string>) |
| 85 | + |FROM VALUES (array(1, 1), map('1', 1), struct(1, 'a')) t(a, b, c) |
| 86 | + """.stripMargin).collect() |
| 87 | + }.getMessage |
| 88 | + assert(e2.contains("TRANSFORM without serde don't support" + |
| 89 | + " ArrayType/MapType/StructType as output data type")) |
| 90 | + |
| 91 | + // check for StructType |
| 92 | + val e3 = intercept[SparkException] { |
| 93 | + sql( |
| 94 | + """ |
| 95 | + |SELECT TRANSFORM(c) |
| 96 | + |USING 'cat' AS (c struct<col1:int, col2:string>) |
| 97 | + |FROM VALUES (array(1, 1), map('1', 1), struct(1, 'a')) t(a, b, c) |
| 98 | + """.stripMargin).collect() |
| 99 | + }.getMessage |
| 100 | + assert(e3.contains("TRANSFORM without serde don't support" + |
| 101 | + " ArrayType/MapType/StructType as output data type")) |
| 102 | + } |
64 | 103 | } |
0 commit comments