Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/18142#discussion_r119159618
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala
---
@@ -1152,27 +1151,27 @@ class SessionCatalog(
// Note: the implementation of this function is a little bit
convoluted.
// We probably shouldn't use a single FunctionRegistry to register all
three kinds of functions
// (built-in, temp, and external).
- if (name.database.isEmpty &&
functionRegistry.functionExists(name.funcName)) {
+ if (name.database.isEmpty && functionRegistry.functionExists(name)) {
// This function has been already loaded into the function registry.
- return functionRegistry.lookupFunction(name.funcName, children)
+ return functionRegistry.lookupFunction(name, children)
}
// If the name itself is not qualified, add the current database to it.
- val database =
name.database.orElse(Some(currentDb)).map(formatDatabaseName)
- val qualifiedName = name.copy(database = database)
+ val database =
formatDatabaseName(name.database.getOrElse(getCurrentDatabase))
+ val qualifiedName = name.copy(database = Some(database))
- if (functionRegistry.functionExists(qualifiedName.unquotedString)) {
+ if (functionRegistry.functionExists(qualifiedName)) {
// This function has been already loaded into the function registry.
// Unlike the above block, we find this function by using the
qualified name.
- return functionRegistry.lookupFunction(qualifiedName.unquotedString,
children)
+ return functionRegistry.lookupFunction(qualifiedName, children)
}
// The function has not been loaded to the function registry, which
means
// that the function is a permanent function (if it actually has been
registered
// in the metastore). We need to first put the function in the
FunctionRegistry.
// TODO: why not just check whether the function exists first?
val catalogFunction = try {
- externalCatalog.getFunction(currentDb, name.funcName)
--- End diff --
This is another bug that blocks users to use the function qualified for the
other database. For example,
```SQL
SELECT db1.test_avg(1)
```
---
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]