You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/06/20 07:02:56 UTC

[GitHub] [spark] AngersZhuuuu commented on a change in pull request #24909: [SPARK-28106][SQL] When Spark SQL use "add jar" , before add to SparkContext, check jar path exist first.

AngersZhuuuu commented on a change in pull request #24909: [SPARK-28106][SQL] When Spark SQL use  "add jar" ,  before add to SparkContext, check  jar path exist first.
URL: https://github.com/apache/spark/pull/24909#discussion_r295668782
 
 

 ##########
 File path: core/src/main/scala/org/apache/spark/SparkContext.scala
 ##########
 @@ -1799,6 +1799,20 @@ class SparkContext(config: SparkConf) extends Logging {
         // For local paths with backslashes on Windows, URI throws an exception
         addJarFile(new File(path))
       } else {
+        /**
+          * Check Path valid
+          */
+        val uriPath = new Path(path).toUri
+        val schemeCorrectedPath = uriPath.getScheme match {
+          case null => new File(path).getCanonicalFile.toURI.toString
+          case "local" => "file:" + uriPath.getPath
+          case _ => path
+        }
+        val hadoopPath = new Path(schemeCorrectedPath)
+        val fs = hadoopPath.getFileSystem(hadoopConfiguration)
+        if(!fs.exists(hadoopPath))
+          throw new FileNotFoundException(s"Jar ${schemeCorrectedPath} not found")
 
 Review comment:
   @jerryshao when Add File, it will call fs.getFileStatus,  it will check if the path is a file or a dir, this action will return exception when we add a wrong path of file.  
   
   `19/06/20 14:59:45 ERROR org.apache.spark.sql.hive.thriftserver.SparkExecuteStatementOperation: "Error executing query, currentState RUNNING, "
   java.io.FileNotFoundException: /userd
   	at org.apache.hadoop.fs.viewfs.InodeTree.resolve(InodeTree.java:403)
   	at org.apache.hadoop.fs.viewfs.ViewFileSystem.getFileStatus(ViewFileSystem.java:377)
   	at org.apache.spark.SparkContext.addFile(SparkContext.scala:1546)
   	at org.apache.spark.SparkContext.addFile(SparkContext.scala:1510)
   	at org.apache.spark.sql.execution.command.AddFileCommand.run(resources.scala:50)
   	at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult$lzycompute(commands.scala:70)
   	at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult(commands.scala:68)
   	at org.apache.spark.sql.execution.command.ExecutedCommandExec.executeCollect(commands.scala:79)
   	at org.apache.spark.sql.Dataset$$anonfun$6.apply(Dataset.scala:195)
   	at org.apache.spark.sql.Dataset$$anonfun$6.apply(Dataset.scala:195)
   	at org.apache.spark.sql.Dataset$$anonfun$53.apply(Dataset.scala:3365)
   	at org.apache.spark.sql.execution.SQLExecution$.withCustomJobTag(SQLExecution.scala:119)
   	at org.apache.spark.sql.execution.SQLExecution$$anonfun$withNewExecutionId$1.apply(SQLExecution.scala:79)
   	at org.apache.spark.sql.execution.SQLExecution$.withSQLConfPropagated(SQLExecution.scala:143)
   	at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:73)
   	at org.apache.spark.sql.Dataset.withAction(Dataset.scala:3364)
   	at org.apache.spark.sql.Dataset.<init>(Dataset.scala:195)
   	at org.apache.spark.sql.Dataset$.ofRows(Dataset.scala:80)
   	at org.apache.spark.sql.SparkSession.sql(SparkSessi`

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

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