Skip to content

Commit 17e3ee0

Browse files
itholicMaxGekk
authored andcommitted
[SPARK-42320][SQL] Assign name to _LEGACY_ERROR_TEMP_2188
### What changes were proposed in this pull request? This PR proposes to assign name to _LEGACY_ERROR_TEMP_2188, "CANNOT_RECOGNIZE_HIVE_TYPE". ### Why are the changes needed? We should assign proper name to _LEGACY_ERROR_TEMP_* ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? `./build/sbt "sql/testOnly org.apache.spark.sql.SQLQueryTestSuite*` Closes #39888 from itholic/LEGACY_2188. Authored-by: itholic <[email protected]> Signed-off-by: Max Gekk <[email protected]>
1 parent 537c04f commit 17e3ee0

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

core/src/main/resources/error/error-classes.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@
9999
],
100100
"sqlState" : "22007"
101101
},
102+
"CANNOT_RECOGNIZE_HIVE_TYPE" : {
103+
"message" : [
104+
"Cannot recognize hive type string: <fieldType>, column: <fieldName>."
105+
],
106+
"sqlState" : "429BB"
107+
},
102108
"CANNOT_RESTORE_PERMISSIONS_FOR_PATH" : {
103109
"message" : [
104110
"Failed to set permissions on created path <path> back to <permission>."
@@ -4470,11 +4476,6 @@
44704476
"<message>, db: <dbName>, table: <tableName>."
44714477
]
44724478
},
4473-
"_LEGACY_ERROR_TEMP_2188" : {
4474-
"message" : [
4475-
"Cannot recognize hive type string: <fieldType>, column: <fieldName>."
4476-
]
4477-
},
44784479
"_LEGACY_ERROR_TEMP_2189" : {
44794480
"message" : [
44804481
"Hive 2.2 and lower versions don't support getTablesByType. Please use Hive 2.3 or higher version."

sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,10 +1844,10 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase {
18441844
def cannotRecognizeHiveTypeError(
18451845
e: ParseException, fieldType: String, fieldName: String): Throwable = {
18461846
new SparkException(
1847-
errorClass = "_LEGACY_ERROR_TEMP_2188",
1847+
errorClass = "CANNOT_RECOGNIZE_HIVE_TYPE",
18481848
messageParameters = Map(
1849-
"fieldType" -> fieldType,
1850-
"fieldName" -> fieldName),
1849+
"fieldType" -> toSQLType(fieldType),
1850+
"fieldName" -> toSQLId(fieldName)),
18511851
cause = e)
18521852
}
18531853

sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,21 @@ class HiveCatalogedDDLSuite extends DDLSuite with TestHiveSingleton with BeforeA
156156
}
157157

158158
test("SPARK-22431: illegal nested type") {
159-
val queries = Seq(
160-
"CREATE TABLE t USING hive AS SELECT STRUCT('a' AS `$a`, 1 AS b) q",
161-
"CREATE TABLE t(q STRUCT<`$a`:INT, col2:STRING>, i1 INT) USING hive")
159+
checkError(
160+
exception = intercept[SparkException] {
161+
spark.sql("CREATE TABLE t USING hive AS SELECT STRUCT('a' AS `$a`, 1 AS b) q")
162+
},
163+
errorClass = "CANNOT_RECOGNIZE_HIVE_TYPE",
164+
parameters = Map("fieldType" -> "\"STRUCT<$A:STRING,B:INT>\"", "fieldName" -> "`q`")
165+
)
162166

163-
queries.foreach(query => {
164-
val err = intercept[SparkException] {
165-
spark.sql(query)
166-
}.getMessage
167-
assert(err.contains("Cannot recognize hive type string"))
168-
})
167+
checkError(
168+
exception = intercept[SparkException] {
169+
spark.sql("CREATE TABLE t(q STRUCT<`$a`:INT, col2:STRING>, i1 INT) USING hive")
170+
},
171+
errorClass = "CANNOT_RECOGNIZE_HIVE_TYPE",
172+
parameters = Map("fieldType" -> "\"STRUCT<$A:INT,COL2:STRING>\"", "fieldName" -> "`q`")
173+
)
169174

170175
withView("v") {
171176
spark.sql("CREATE VIEW v AS SELECT STRUCT('a' AS `a`, 1 AS b) q")

0 commit comments

Comments
 (0)