是否可以在 Windows 上使用 Scala 语言的 SparkSession object 读取文件?

Is it possible to read a file using SparkSession object of Scala language on Windows?

我一直在尝试使用 SparkContext object 以多种方式读取 .csv 文件。我发现可以通过 scala.io.Source.fromFile 函数实现,但我想使用 spark object。每次我 运行 函数 textfileorg.apache.spark.SparkContext 我得到同样的错误:

scala>     sparkSession.read.csv("file://C:\Users\184229\Desktop\bigdata.csv")


21/12/29 16:47:32 WARN streaming.FileStreamSink: Error while looking for metadata directory.

java.lang.UnsupportedOperationException: Not implemented by the DistributedFileSystem FileSystem implementation
.....

如标题中所述,我 运行 IntelliJ Windows 上的代码

[编辑] 在 build.sbt 中没有冗余或重叠的依赖项。我使用 hadoop-tools、spark-sql 和 hadoop-xz。

您是否尝试过 运行 您的 spark-shell 使用本地模式?

spark-shell --master=local

还要注意不要同时使用 Hadoop-code 和 Hadoop-commons 作为依赖项,因为您可能会遇到 jars 冲突问题。

我找到了解决方案,正是我的一位同事做到的。 在依赖项 build.sbt 中,我将 hadoop-tools 更改为 hadoop-commons 并且成功了。