This is an automated email from the ASF dual-hosted git repository. srowen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push: new d003db3 [SPARK-36550][SQL] Propagation cause when UDF reflection fails d003db3 is described below commit d003db34c4c5c52a8c99ceecf7233a9b19a69b81 Author: sychen <syc...@ctrip.com> AuthorDate: Wed Sep 29 08:30:50 2021 -0500 [SPARK-36550][SQL] Propagation cause when UDF reflection fails ### What changes were proposed in this pull request? When the exception is InvocationTargetException, get cause and stack trace. ### Why are the changes needed? Now when UDF reflection fails, InvocationTargetException is thrown, but it is not a specific exception. ``` Error in query: No handler for Hive UDF 'XXX': java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ``` ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? manual test Closes #33796 from cxzl25/SPARK-36550. Authored-by: sychen <syc...@ctrip.com> Signed-off-by: Sean Owen <sro...@gmail.com> --- .../main/scala/org/apache/spark/sql/hive/HiveSessionCatalog.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveSessionCatalog.scala b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveSessionCatalog.scala index 7cbaa8a..56818b5 100644 --- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveSessionCatalog.scala +++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveSessionCatalog.scala @@ -17,6 +17,7 @@ package org.apache.spark.sql.hive +import java.lang.reflect.InvocationTargetException import java.util.Locale import scala.util.{Failure, Success, Try} @@ -87,7 +88,11 @@ private[sql] class HiveSessionCatalog( udfExpr.get.asInstanceOf[HiveGenericUDTF].elementSchema } } catch { - case NonFatal(e) => + case NonFatal(exception) => + val e = exception match { + case i: InvocationTargetException => i.getCause + case o => o + } val errorMsg = s"No handler for UDF/UDAF/UDTF '${clazz.getCanonicalName}': $e" val analysisException = new AnalysisException(errorMsg) analysisException.setStackTrace(e.getStackTrace) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org