Skip to content

Commit ad958d4

Browse files
michaelmitchell-bitMaxGekk
authored andcommitted
[SPARK-57752][SPARK-57753][SPARK-57754][SQL] Assign names to Hive UDF Java type error conditions
### What changes were proposed in this pull request? This PR assigns named error conditions and SQLSTATEs for three Hive UDF/UDAF/UDTF Java type legacy error classes: - `_LEGACY_ERROR_TEMP_3090` -> `UNSUPPORTED_HIVE_FUNCTION_TYPE.RAW_LIST` - `_LEGACY_ERROR_TEMP_3091` -> `UNSUPPORTED_HIVE_FUNCTION_TYPE.RAW_MAP` - `_LEGACY_ERROR_TEMP_3092` -> `UNSUPPORTED_HIVE_FUNCTION_TYPE.WILDCARD` The three conditions share the `UNSUPPORTED_HIVE_FUNCTION_TYPE` parent with SQLSTATE `0A000` because all three cases reject unsupported Hive function Java type signatures while Spark infers Catalyst types. ### Why are the changes needed? To replace temporary legacy error classes with stable named error conditions and SQLSTATEs. ### Does this PR introduce _any_ user-facing change? Yes. The affected errors now report named error conditions and SQLSTATEs, and their messages are grouped under the new `UNSUPPORTED_HIVE_FUNCTION_TYPE` condition. ### How was this patch tested? Ran targeted tests: ``` ./build/sbt "core/testOnly org.apache.spark.SparkThrowableSuite" ./build/sbt "hive/testOnly org.apache.spark.sql.hive.execution.HiveUDFSuite -- -z \"UDFRaw\"" ./build/sbt "hive/testOnly org.apache.spark.sql.hive.execution.HiveUDFSuite -- -z \"UDFWildcardList\"" ``` Also ran: ``` jq empty common/utils/src/main/resources/error/error-conditions.json git diff --check ``` ### Was this patch authored or co-authored using generative AI tooling? Generated-by: OpenAI Codex Closes #56905 from michaelmitchell-bit/SPARK-57752-57753-57754-hive-udf-error-classes. Authored-by: michaelmitchell-bit <hiremichaeltech@gmail.com> Signed-off-by: Max Gekk <max.gekk@gmail.com>
1 parent 156d0aa commit ad958d4

3 files changed

Lines changed: 32 additions & 21 deletions

File tree

common/utils/src/main/resources/error/error-conditions.json

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8626,6 +8626,29 @@
86268626
],
86278627
"sqlState" : "42K0E"
86288628
},
8629+
"UNSUPPORTED_HIVE_FUNCTION_TYPE" : {
8630+
"message" : [
8631+
"Unsupported Hive UDF/UDAF/UDTF Java type:"
8632+
],
8633+
"subClass" : {
8634+
"RAW_LIST" : {
8635+
"message" : [
8636+
"raw java.util.List. Spark cannot infer the element type."
8637+
]
8638+
},
8639+
"RAW_MAP" : {
8640+
"message" : [
8641+
"raw java.util.Map. Spark cannot infer the key and value types."
8642+
]
8643+
},
8644+
"WILDCARD" : {
8645+
"message" : [
8646+
"wildcard type parameter. Spark cannot infer a concrete data type for wildcard type parameters, such as List<?> or Map<?, ?>."
8647+
]
8648+
}
8649+
},
8650+
"sqlState" : "0A000"
8651+
},
86298652
"UNSUPPORTED_HIVE_METASTORE_VERSION_FOR_JAVA" : {
86308653
"message" : [
86318654
"Hive metastore version <version> requires Java <requiredJavaVersion> or later, but the current JVM is Java <currentJavaVersion>. Please upgrade your Java version or use an earlier Hive metastore version."
@@ -11368,21 +11391,6 @@
1136811391
"Corrupted <typeName> in catalog: <numCols> parts expected, but part <index> is missing."
1136911392
]
1137011393
},
11371-
"_LEGACY_ERROR_TEMP_3090" : {
11372-
"message" : [
11373-
"Raw list type in java is unsupported because Spark cannot infer the element type."
11374-
]
11375-
},
11376-
"_LEGACY_ERROR_TEMP_3091" : {
11377-
"message" : [
11378-
"Raw map type in java is unsupported because Spark cannot infer key and value types."
11379-
]
11380-
},
11381-
"_LEGACY_ERROR_TEMP_3092" : {
11382-
"message" : [
11383-
"Collection types with wildcards (e.g. List<?> or Map<?, ?>) are unsupported because Spark cannot infer the data type for these type parameters."
11384-
]
11385-
},
1138611394
"_LEGACY_ERROR_TEMP_3093" : {
1138711395
"message" : [
1138811396
"Unsupported java type <c>"

sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveInspectors.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,16 +241,19 @@ private[hive] trait HiveInspectors {
241241
// raw java list type unsupported
242242
case c: Class[_] if isSubClassOf(c, classOf[java.util.List[_]]) =>
243243
throw new AnalysisException(
244-
errorClass = "_LEGACY_ERROR_TEMP_3090", messageParameters = Map.empty)
244+
errorClass = "UNSUPPORTED_HIVE_FUNCTION_TYPE.RAW_LIST",
245+
messageParameters = Map.empty)
245246

246247
// raw java map type unsupported
247248
case c: Class[_] if isSubClassOf(c, classOf[java.util.Map[_, _]]) =>
248249
throw new AnalysisException(
249-
errorClass = "_LEGACY_ERROR_TEMP_3091", messageParameters = Map.empty)
250+
errorClass = "UNSUPPORTED_HIVE_FUNCTION_TYPE.RAW_MAP",
251+
messageParameters = Map.empty)
250252

251253
case _: WildcardType =>
252254
throw new AnalysisException(
253-
errorClass = "_LEGACY_ERROR_TEMP_3092", messageParameters = Map.empty)
255+
errorClass = "UNSUPPORTED_HIVE_FUNCTION_TYPE.WILDCARD",
256+
messageParameters = Map.empty)
254257

255258
case c => throw new AnalysisException(
256259
errorClass = "_LEGACY_ERROR_TEMP_3093", messageParameters = Map("c" -> c.toString))

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ class HiveUDFSuite extends QueryTest with TestHiveSingleton {
293293
val err = intercept[AnalysisException](sql("SELECT testUDFRawList(s) FROM inputTable"))
294294
checkError(
295295
exception = err.getCause.asInstanceOf[AnalysisException],
296-
condition = "_LEGACY_ERROR_TEMP_3090",
296+
condition = "UNSUPPORTED_HIVE_FUNCTION_TYPE.RAW_LIST",
297297
parameters = Map.empty)
298298

299299
sql("DROP TEMPORARY FUNCTION IF EXISTS testUDFRawList")
@@ -309,7 +309,7 @@ class HiveUDFSuite extends QueryTest with TestHiveSingleton {
309309
val err = intercept[AnalysisException](sql("SELECT testUDFRawMap(s) FROM inputTable"))
310310
checkError(
311311
exception = err.getCause.asInstanceOf[AnalysisException],
312-
condition = "_LEGACY_ERROR_TEMP_3091",
312+
condition = "UNSUPPORTED_HIVE_FUNCTION_TYPE.RAW_MAP",
313313
parameters = Map.empty)
314314

315315
sql("DROP TEMPORARY FUNCTION IF EXISTS testUDFRawMap")
@@ -325,7 +325,7 @@ class HiveUDFSuite extends QueryTest with TestHiveSingleton {
325325
val err = intercept[AnalysisException](sql("SELECT testUDFWildcardList(s) FROM inputTable"))
326326
checkError(
327327
exception = err.getCause.asInstanceOf[AnalysisException],
328-
condition = "_LEGACY_ERROR_TEMP_3092",
328+
condition = "UNSUPPORTED_HIVE_FUNCTION_TYPE.WILDCARD",
329329
parameters = Map.empty)
330330

331331
sql("DROP TEMPORARY FUNCTION IF EXISTS testUDFWildcardList")

0 commit comments

Comments
 (0)