viirya commented on a change in pull request #25452: [SPARK-28710][SQL]to fix replace function, spark should call drop and create function URL: https://github.com/apache/spark/pull/25452#discussion_r358329968
########## File path: sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveExternalCatalog.scala ########## @@ -1282,7 +1282,16 @@ private[spark] class HiveExternalCatalog(conf: SparkConf, hadoopConf: Configurat val functionName = funcDefinition.identifier.funcName.toLowerCase(Locale.ROOT) requireFunctionExists(db, functionName) val functionIdentifier = funcDefinition.identifier.copy(funcName = functionName) - client.alterFunction(db, funcDefinition.copy(identifier = functionIdentifier)) + val newDefinition = funcDefinition.copy(identifier = functionIdentifier) + isResourceChanged(db, newDefinition) match { + // as of now Hive only alter name, owner, class name, type but not resource URI + // So in order to replace function with resource spark needs to delete and create the function + case true => client.dropFunction(db, functionName) + client.createFunction(db, newDefinition) Review comment: this style looks uncommon in Spark. We have it usually: ```scala isResourceChanged(db, newDefinition) match { case true => client.dropFunction(db, functionName) client.createFunction(db, newDefinition) ... } ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org