Apache spark org.apache.spark.sql.AnalysisException:路径不存在

Apache spark org.apache.spark.sql.AnalysisException:路径不存在,apache-spark,Apache Spark,我在尝试读取fat jar中作为资源存储的拼花地板文件时遇到问题,因此我尝试了以下代码来读取资源文件并将其复制到磁盘上: val inputFile = "test.parquet" val parquetFile = "/part-r-00000-2185f9a7-ea70-41be-95d2-e9f70f93c43b.parquet" FileUtils.copyInputStreamToFile(Main2.getClass.getResourceAsStream(parquetFile)

我在尝试读取fat jar中作为资源存储的拼花地板文件时遇到问题,因此我尝试了以下代码来读取资源文件并将其复制到磁盘上:

val inputFile = "test.parquet"
val parquetFile = "/part-r-00000-2185f9a7-ea70-41be-95d2-e9f70f93c43b.parquet"
FileUtils.copyInputStreamToFile(Main2.getClass.getResourceAsStream(parquetFile), new File(inputFile))
    LOGGER.info("saved resource to external file")
此代码成功运行。但当我尝试使用以下命令读取文件时:

spark.sqlContext.read.parquet(inputFile)
我得到这个错误:

ERROR yarn.ApplicationMaster: User class threw exception: org.apache.spark.sql.AnalysisException: Path does not exist: hdfs://nameservice1/user/me/test.parquet
我怎样才能解决这个问题?我只想能够读取作为资源存储在fat jar中的拼花地板文件。我试过很多东西,但都不管用

FileUtils.copyInputStreamToFile
将Fat jar中文件的输入流复制到本地文件系统,而不是分布式文件系统(即HDFS)中。 试试下面的代码应该可以

spark.sqlContext.read.parquet("file:////<  absolute path of inputFile >")
spark.sqlContext.read.parquet(“file:////<输入文件的绝对路径>”)