sandeep-katta 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_r358597386
########## 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) + // replace the function in the metastore if there is no change in the resource + case _ => + client.alterFunction(db, newDefinition) Review comment: And also initially in the [jira](https://issues.apache.org/jira/browse/SPARK-28710), I proposed 2 solutions for this bug solution 1: throw Unsupported Error for permanent function solution 2: instead of alter function, do drop and create ---------------------------------------------------------------- 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