File tree Expand file tree Collapse file tree 3 files changed +8
-5
lines changed
catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog
main/scala/org/apache/spark/sql/execution/command
test/scala/org/apache/spark/sql/execution/command Expand file tree Collapse file tree 3 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -1344,8 +1344,8 @@ class SessionCatalog(
13441344 /**
13451345 * Unregister a temporary or permanent function from a session-specific [[FunctionRegistry ]]
13461346 */
1347- def unregisterFunction (name : FunctionIdentifier ): Unit = {
1348- if (! functionRegistry.dropFunction(name)) {
1347+ def unregisterFunction (name : FunctionIdentifier , ignoreIfNotExists : Boolean ): Unit = {
1348+ if (! functionRegistry.dropFunction(name) && ! ignoreIfNotExists ) {
13491349 throw new NoSuchFunctionException (
13501350 formatDatabaseName(name.database.getOrElse(currentDb)), name.funcName)
13511351 }
Original file line number Diff line number Diff line change @@ -266,8 +266,9 @@ case class RefreshFunctionCommand(
266266 val func = catalog.getFunctionMetadata(identifier)
267267 catalog.registerFunction(func, true )
268268 } else {
269- // clear cached function.
270- catalog.unregisterFunction(identifier)
269+ // clear cached function if exists.
270+ catalog.unregisterFunction(identifier, true )
271+ throw new NoSuchFunctionException (identifier.database.get, functionName)
271272 }
272273
273274 Seq .empty[Row ]
Original file line number Diff line number Diff line change @@ -3058,7 +3058,9 @@ abstract class DDLSuite extends QueryTest with SQLTestUtils {
30583058
30593059 spark.sessionState.catalog.externalCatalog.dropFunction(" default" , " func1" )
30603060 assert(spark.sessionState.catalog.isRegisteredFunction(func))
3061- sql(" REFRESH FUNCTION func1" )
3061+ intercept[NoSuchFunctionException ] {
3062+ sql(" REFRESH FUNCTION func1" )
3063+ }
30623064 assert(! spark.sessionState.catalog.isRegisteredFunction(func))
30633065
30643066 val function = CatalogFunction (func, " test.non.exists.udf" , Seq .empty)
You can’t perform that action at this time.
0 commit comments