dilipbiswal commented on a change in pull request #25399: [SPARK-28670][SQL] 
create function should thrown Exception if the resource is not found
URL: https://github.com/apache/spark/pull/25399#discussion_r312691081
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/functions.scala
 ##########
 @@ -75,9 +76,18 @@ case class CreateFunctionCommand(
   override def run(sparkSession: SparkSession): Seq[Row] = {
     val catalog = sparkSession.sessionState.catalog
     val func = CatalogFunction(FunctionIdentifier(functionName, databaseName), 
className, resources)
+    // throws Exception if it does not find the resource
+    def checkIfResourceExists = {
+      resources.foreach(
+        resource =>
+          if (!Utils.isFileExists(resource.uri, 
sparkSession.sparkContext.hadoopConfiguration)) {
+            throw new AnalysisException(s" Could not find the resource 
${resource.uri}")
+          }
+      )
+    }
     if (isTemp) {
       // We first load resources and then put the builder in the function 
registry.
-      catalog.loadFunctionResources(resources)
+      checkIfResourceExists
 
 Review comment:
   Previously we used to load the function resources. We don't need to do that 
any more ? Is it done some place else ? If so, we need to adjust the comment 
above.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to