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_r358595078
 
 

 ##########
 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:
   yes, as of now Hive only alter name, owner, class name, type but not 
resource URI. There is no replace DDL in Hive

----------------------------------------------------------------
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

Reply via email to