Skip to content

Commit c48e381

Browse files
PavithraRamachandranmaropu
authored andcommitted
[SPARK-28671][SQL] Throw NoSuchPermanentFunctionException for a non-exsistent permanent function in dropFunction/alterFunction
## What changes were proposed in this pull request? **Before Fix** When a non existent permanent function is dropped, generic NoSuchFunctionException was thrown.- which printed "This function is neither a registered temporary function nor a permanent function registered in the database" . This creates a ambiguity when a temp function in the same name exist. **After Fix** NoSuchPermanentFunctionException will be thrown, which will print "NoSuchPermanentFunctionException:Function not found in database " ## How was this patch tested? Unit test was run and corrected the UT. Closes #25394 from PavithraRamachandran/funcIssue. Lead-authored-by: pavithra <[email protected]> Co-authored-by: pavithraramachandran <[email protected]> Signed-off-by: Takeshi Yamamuro <[email protected]>
1 parent ef14237 commit c48e381

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ class SessionCatalog(
11141114
}
11151115
externalCatalog.dropFunction(db, name.funcName)
11161116
} else if (!ignoreIfNotExists) {
1117-
throw new NoSuchFunctionException(db = db, func = identifier.toString)
1117+
throw new NoSuchPermanentFunctionException(db = db, func = identifier.toString)
11181118
}
11191119
}
11201120

@@ -1137,7 +1137,7 @@ class SessionCatalog(
11371137
}
11381138
externalCatalog.alterFunction(db, newFuncDefinition)
11391139
} else {
1140-
throw new NoSuchFunctionException(db = db, func = identifier.toString)
1140+
throw new NoSuchPermanentFunctionException(db = db, func = identifier.toString)
11411141
}
11421142
}
11431143

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalogSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,7 @@ abstract class SessionCatalogSuite extends AnalysisTest {
14291429
catalog.dropFunction(
14301430
FunctionIdentifier("something", Some("unknown_db")), ignoreIfNotExists = false)
14311431
}
1432-
intercept[NoSuchFunctionException] {
1432+
intercept[NoSuchPermanentFunctionException] {
14331433
catalog.dropFunction(FunctionIdentifier("does_not_exist"), ignoreIfNotExists = false)
14341434
}
14351435
catalog.dropFunction(FunctionIdentifier("does_not_exist"), ignoreIfNotExists = true)

0 commit comments

Comments
 (0)