We had been facing issue with using spark-sftp Jar while downloading a remote SFTP file and creating Dataframe.
Code being executed:
val df = spark.read.format("com.springml.spark.sftp")
.option("host", HOST)
.option("port", PORT)
.option("username", UN)
.option("password", PWD)
.option("fileType", "csv")
.option("inferSchema", "true")
.option("header", "true")
.load(FILENAME)
Error response:
org.apache.spark.sql.AnalysisException: Path does not exist: wasb://...
at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$org$apache$spark$sql$execution$datasources$DataSource$$checkAndGlobPathIfNecessary$1.apply(DataSource.scala:612)
at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$org$apache$spark$sql$execution$datasources$DataSource$$checkAndGlobPathIfNecessary$1.apply(DataSource.scala:595)
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:241)
at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:241)
at scala.collection.immutable.List.foreach(List.scala:381)
at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:241)
at scala.collection.immutable.List.flatMap(List.scala:344)
at org.apache.spark.sql.execution.datasources.DataSource.org$apache$spark$sql$execution$datasources$DataSource$$checkAndGlobPathIfNecessary(DataSource.scala:595)
at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:390)
Analysis:
We found that SFTP is file downloading into local file location as specified by "yarn.nodemanager.local-dirs" when running in Cluster mode, whereas file is being downloaded in local as specified by "spark.local.dir" when running in Client mode.
But, problem is that file is being searched over HDFS/ WASB instead of Local to create Dataframe which results in "Path not exists" exception
It is pointed out here that issue has been fixed in latest version of Jar file - https://github.com/springml/spark-sftp/issues/52. But, we were still getting same exception.
Solution:
We uploaded all the Jar files to HDFS / WASB and pointed same with --jars instead of local file system. Our code worked just fine after placing Jar files on HDFS and using same instead of local file system.
Command when using local file system resulting error -
spark-submit --jars /home/sshuser/ds/sftp.client-1.0.3.jar,/home/sshuser/ds/spark-sftp_2.11-1.1.5.jar,/home/sshuser/ds/spark-sql-kafka-0-10_2.11-2.3.0.jar
Command when using HDFS/ WASB, running successfully -
spark-submit --jars wasb:///home/sshuser/ds/sftp.client-1.0.3.jar,wasb:///home/sshuser/ds/spark-sftp_2.11-1.1.5.jar,wasb:///home/sshuser/ds/spark-sql-kafka-0-10_2.11-2.3.0.jar
Comments
Post a Comment