我在尝试读取作为资源存储在我的fat-jar中的parquet文件时遇到了问题,所以我尝试了以下代码,该代码读取资源文件并将其复制到磁盘上:
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中的拼图文件。我试过很多方法,但都不管用。
发布于 2019-03-08 18:56:01
FileUtils.copyInputStreamToFile将Fat jar中文件的输入流复制到本地文件系统,而不是分布式文件系统,即HDFS。尝试使用下面的代码应该可以
spark.sqlContext.read.parquet("file:////< absolute path of inputFile >")https://stackoverflow.com/questions/43506008
复制相似问题