Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/19747#discussion_r153396224
--- Diff:
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala
---
@@ -174,6 +174,88 @@ class HiveCatalogedDDLSuite extends DDLSuite with
TestHiveSingleton with BeforeA
test("alter datasource table add columns - partitioned - orc") {
testAddColumnPartitioned("orc")
}
+
+ test("SPARK-22431: illegal nested type") {
+ val queries = Seq(
+ "CREATE TABLE t AS SELECT STRUCT('a' AS `$a`, 1 AS b) q",
+ "CREATE TABLE t(q STRUCT<`$a`:INT, col2:STRING>, i1 INT)",
+ "CREATE VIEW t AS SELECT STRUCT('a' AS `$a`, 1 AS b) q")
+
+ queries.foreach(query => {
+ val err = intercept[SparkException] {
+ spark.sql(query)
+ }.getMessage
+ assert(err.contains("Cannot recognize hive type string"))
+ })
+
+ withView("v") {
+ spark.sql("CREATE VIEW v AS SELECT STRUCT('a' AS `a`, 1 AS b) q")
+ checkAnswer(sql("SELECT q.`a`, q.b FROM v"), Row("a", 1) :: Nil)
+
+ val err = intercept[SparkException] {
+ spark.sql("ALTER VIEW v AS SELECT STRUCT('a' AS `$a`, 1 AS b) q")
+ }.getMessage
+ assert(err.contains("Cannot recognize hive type string"))
+ }
+ }
+
+ test("SPARK-22431: table with nested type") {
+ withTable("t", "x") {
+ spark.sql("CREATE TABLE t(q STRUCT<`$a`:INT, col2:STRING>, i1 INT)
USING PARQUET")
+ checkAnswer(sql("SELECT * FROM t"), Nil)
+ spark.sql("CREATE TABLE x (q STRUCT<col1:INT, col2:STRING>, i1 INT)")
+ checkAnswer(sql("SELECT * FROM x"), Nil)
--- End diff --
The same here
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]