Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/18700#discussion_r134397113
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala
---
@@ -1091,13 +1102,49 @@ class SessionCatalog(
// ----------------------------------------------------------------
/**
+ * Constructs a [[FunctionBuilder]] based on the provided class that
represents a function.
+ */
+ protected def makeFunctionBuilder(name: String, functionClassName:
String): FunctionBuilder = {
+ val clazz = Utils.classForName(functionClassName)
+ (children: Seq[Expression]) => {
+ try {
+ makeFunctionExpression(name,
Utils.classForName(functionClassName), children).getOrElse {
+ val extraMsg =
+ if (!isUsingHiveMetastore) "Use sparkSession.udf.register(...)
instead." else ""
+ throw new AnalysisException(
+ s"No handler for UDF/UDAF/UDTF '${clazz.getCanonicalName}'.
$extraMsg")
+ }
+ } catch {
+ case ae: AnalysisException =>
+ throw ae
+ case NonFatal(e) =>
+ val analysisException =
+ new AnalysisException(s"No handler for UDF/UDAF/UDTF
'${clazz.getCanonicalName}': $e")
+ analysisException.setStackTrace(e.getStackTrace)
+ throw analysisException
+ }
+ }
+ }
+
+ /**
* Construct a [[FunctionBuilder]] based on the provided class that
represents a function.
*
* This performs reflection to decide what type of [[Expression]] to
return in the builder.
*/
- protected def makeFunctionBuilder(name: String, functionClassName:
String): FunctionBuilder = {
- // TODO: at least support UDAFs here
- throw new UnsupportedOperationException("Use
sqlContext.udf.register(...) instead.")
+ protected def makeFunctionExpression(
--- End diff --
seems we need to catch exception for this method anyway, how about we just
make this method return `Expression` and document that it can throw exception
if the given class is not supported? Then `HiveSessionCatalog` can define its
own exception message.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]