-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-24544][SQL] Print actual failure cause when look up function failed #21790
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
690035a
e1866d1
ec208e0
26aeb58
95ba6e7
1bff63c
820faf2
240f3ab
6d3bd19
97493c9
d1d4adf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1445,4 +1445,12 @@ abstract class SessionCatalogSuite extends AnalysisTest { | |
| } | ||
| } | ||
| } | ||
|
|
||
| test("SPARK-24544: test print actual failure cause when look up function failed") { | ||
| withBasicCatalog { catalog => | ||
| intercept[NoSuchFunctionException] { | ||
|
||
| catalog.failFunctionLookup(FunctionIdentifier("failureFunc"), Some(new Exception("Test"))) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ import org.apache.spark.sql.catalyst.parser.ParserInterface | |
| import org.apache.spark.sql.hive.HiveShim.HiveFunctionWrapper | ||
| import org.apache.spark.sql.internal.SQLConf | ||
| import org.apache.spark.sql.types.{DecimalType, DoubleType} | ||
| import org.apache.spark.util.Utils | ||
|
|
||
|
|
||
| private[sql] class HiveSessionCatalog( | ||
|
|
@@ -141,21 +142,23 @@ private[sql] class HiveSessionCatalog( | |
| // built-in function. | ||
| // Hive is case insensitive. | ||
| val functionName = funcName.unquotedString.toLowerCase(Locale.ROOT) | ||
| logWarning(s"Encounter a failure during looking up function:" + | ||
|
||
| s" ${Utils.exceptionString(error)}") | ||
| if (!hiveFunctions.contains(functionName)) { | ||
| failFunctionLookup(funcName) | ||
| failFunctionLookup(funcName, Some(error)) | ||
| } | ||
|
|
||
| // TODO: Remove this fallback path once we implement the list of fallback functions | ||
| // defined below in hiveFunctions. | ||
| val functionInfo = { | ||
| try { | ||
| Option(HiveFunctionRegistry.getFunctionInfo(functionName)).getOrElse( | ||
| failFunctionLookup(funcName)) | ||
| failFunctionLookup(funcName, Some(error))) | ||
| } catch { | ||
| // If HiveFunctionRegistry.getFunctionInfo throws an exception, | ||
| // we are failing to load a Hive builtin function, which means that | ||
| // the given function is not a Hive builtin function. | ||
| case NonFatal(e) => failFunctionLookup(funcName) | ||
| case NonFatal(e) => failFunctionLookup(funcName, Some(e)) | ||
| } | ||
| } | ||
| val className = functionInfo.getFunctionClass.getName | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is too complex for string interpolation. But why not just set the exception's cause?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@srowen Thanks.IIUC.Since some times the cause may be undefined.For that case, we do not need to print
Exception thrown during look up.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, why not set the cause on
AnalysisException? the cause may be null if the Option is None, that's fine.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update @srowen Thanks!