Github user andrewor14 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12117#discussion_r58600078
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/functions.scala 
---
    @@ -85,24 +91,23 @@ case class DropFunction(
       extends RunnableCommand {
     
       override def run(sqlContext: SQLContext): Seq[Row] = {
    +    val catalog = sqlContext.sessionState.catalog
         if (isTemp) {
           if (databaseName.isDefined) {
             throw new AnalysisException(
               s"It is not allowed to provide database name when dropping a 
temporary function. " +
                 s"However, database name ${databaseName.get} is provided.")
           }
    -      sqlContext.sessionState.catalog.dropTempFunction(functionName, 
ifExists)
    +      catalog.dropTempFunction(functionName, ifExists)
         } else {
    -      // We are dropping a permanent.
    -      val dbName = 
databaseName.getOrElse(sqlContext.sessionState.catalog.getCurrentDatabase)
    +      // We are dropping a permanent function.
    +      val dbName = databaseName.getOrElse(catalog.getCurrentDatabase)
           val func = FunctionIdentifier(functionName, Some(dbName))
    -      if (!ifExists) {
    -        if (!sqlContext.sessionState.catalog.functionExists(func)) {
    -          throw new AnalysisException(
    -            s"Function '$functionName' does not exist in database 
'$dbName'.")
    -        }
    +      if (!ifExists && !catalog.functionExists(func)) {
    +        throw new AnalysisException(
    +          s"Function '$functionName' does not exist in database 
'$dbName'.")
    --- End diff --
    
    I still think this should be handled within `dropFunction` itself (by 
passing the `ifExists` flag), but not a big deal


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to