Github user andrewor14 commented on a diff in the pull request:
https://github.com/apache/spark/pull/12036#discussion_r57960666
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala ---
@@ -193,7 +230,28 @@ case class DropFunction(
functionName: String,
ifExists: Boolean,
isTemp: Boolean)(sql: String)
- extends NativeDDLCommand(sql) with Logging
+ extends NativeDDLCommand(sql) with Logging {
+
+ override def run(sqlContext: SQLContext): Seq[Row] = {
+ if (isTemp) {
+ require(databaseName.isEmpty,
+ "attempted to drop a temporary function while specifying a
database")
+ sqlContext.sessionState.catalog.dropTempFunction(functionName,
ifExists)
+ } else {
+ val func = FunctionIdentifier(functionName, databaseName)
+ if (!ifExists) {
+ // getFunction can throw NoSuchFunctionException itself, or return
null.
+ val existingFunc =
sqlContext.sessionState.catalog.getFunction(func)
+ if (existingFunc == null) {
+ val dbName =
databaseName.getOrElse(sqlContext.sessionState.catalog.getCurrentDatabase)
+ throw new NoSuchFunctionException(dbName, functionName)
--- End diff --
we should just be consistent and throw `AnalysisException` here. Once you
added `functionExists` to the session catalog then you can just check on that
instead of trying to get the function here yourself.
---
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]