Skip to content

Commit 181d190

Browse files
OCaballeroHyukjinKwon
authored andcommitted
[MINOR][SQL] Unnecessary access to externalCatalog
Necessarily access the external catalog without having to do it ## What changes were proposed in this pull request? The existsFunction function has been changed because it unnecessarily accessed the externalCatalog to find if the database exists in cases where the function is in the functionRegistry ## How was this patch tested? It has been tested through spark-shell and accessing the metastore logs of hive. Inside spark-shell we use spark.table (% tableA%). SelectExpr ("trim (% columnA%)") in the current version and it appears every time: org.apache.hadoop.hive.metastore.HiveMetaStore.audit: cmd = get_database: default Once the change is made, no record appears Closes apache#24312 from OCaballero/master. Authored-by: ocaballero <[email protected]> Signed-off-by: HyukjinKwon <[email protected]>
1 parent ab8710b commit 181d190

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,10 +1105,11 @@ class SessionCatalog(
11051105
* Check if the function with the specified name exists
11061106
*/
11071107
def functionExists(name: FunctionIdentifier): Boolean = {
1108-
val db = formatDatabaseName(name.database.getOrElse(getCurrentDatabase))
1109-
requireDbExists(db)
1110-
functionRegistry.functionExists(name) ||
1108+
functionRegistry.functionExists(name) || {
1109+
val db = formatDatabaseName(name.database.getOrElse(getCurrentDatabase))
1110+
requireDbExists(db)
11111111
externalCatalog.functionExists(db, name.funcName)
1112+
}
11121113
}
11131114

11141115
// ----------------------------------------------------------------

0 commit comments

Comments
 (0)