Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/18142#discussion_r119014081
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/FunctionRegistry.scala
---
@@ -17,51 +17,74 @@
package org.apache.spark.sql.catalyst.analysis
-import java.lang.reflect.Modifier
+import java.util.Locale
+import javax.annotation.concurrent.GuardedBy
+import scala.collection.mutable
import scala.language.existentials
import scala.reflect.ClassTag
import scala.util.{Failure, Success, Try}
import org.apache.spark.sql.AnalysisException
+import org.apache.spark.sql.catalyst.FunctionIdentifier
import
org.apache.spark.sql.catalyst.analysis.FunctionRegistry.FunctionBuilder
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.expressions.aggregate._
import org.apache.spark.sql.catalyst.expressions.xml._
-import org.apache.spark.sql.catalyst.util.StringKeyHashMap
import org.apache.spark.sql.types._
/**
* A catalog for looking up user defined functions, used by an
[[Analyzer]].
*
- * Note: The implementation should be thread-safe to allow concurrent
access.
+ * Note:
+ * 1) The implementation should be thread-safe to allow concurrent
access.
+ * 2) the database name is always case-sensitive here, callers are
responsible to
+ * format the database name w.r.t. case-sensitive config.
*/
trait FunctionRegistry {
- final def registerFunction(name: String, builder: FunctionBuilder): Unit
= {
- registerFunction(name, new
ExpressionInfo(builder.getClass.getCanonicalName, name), builder)
+ final def registerFunction(name: FunctionIdentifier, builder:
FunctionBuilder): Unit = {
+ val info = new ExpressionInfo(
+ builder.getClass.getCanonicalName, name.database.orNull,
name.funcName)
+ registerFunction(name, info, builder)
}
- def registerFunction(name: String, info: ExpressionInfo, builder:
FunctionBuilder): Unit
+ def registerFunction(
+ name: FunctionIdentifier,
+ info: ExpressionInfo,
+ builder: FunctionBuilder): Unit
+
+ /* Create or replace a temporary function. */
+ final def createOrReplaceTempFunction(name: String, builder:
FunctionBuilder): Unit = {
--- End diff --
Since we already expose `FunctionRegistry` to the stable class
`UDFRegistration`, I added this extra API for a helper function.
Ideally, this function should only exist in `SessionCatalog`.
---
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]