我已经尝试解决这个问题很长时间了......不知道为什么我会得到这个?仅供引用,我正在 AWS EMR 集群上的集群上运行 Spark。我调试并清楚地看到提供的目标路径...类似 s3://my-bucket-name/
。 Spark 作业创建 orc 文件并在创建分区后写入它们,如下所示:date=2017-06-10
。有什么想法吗?
17/07/08 22:48:31 ERROR ApplicationMaster: User class threw exception: java.lang.IllegalArgumentException: Can not create a Path from an empty string
java.lang.IllegalArgumentException: Can not create a Path from an empty string
at org.apache.hadoop.fs.Path.checkPathArg(Path.java:126)
at org.apache.hadoop.fs.Path.<init>(Path.java:134)
at org.apache.hadoop.fs.Path.<init>(Path.java:93)
at org.apache.hadoop.fs.Path.suffix(Path.java:361)
at org.apache.spark.sql.execution.datasources.InsertIntoHadoopFsRelationCommand.deleteMatchingPartitions(InsertIntoHadoopFsRelationCommand.scala:138)
at org.apache.spark.sql.execution.datasources.InsertIntoHadoopFsRelationCommand.run(InsertIntoHadoopFsRelationCommand.scala:82)
编写orc的代码:
dataframe.write
.partitionBy(partition)
.option("compression", ZLIB.toString)
.mode(SaveMode.Overwrite)
.orc(destination)
最佳答案
在将 parquet 文件写入 S3 时,我也遇到过类似的问题。问题在于SaveMode.Overwrite
。此模式与 S3 结合使用时似乎无法正常工作。在写入 S3 存储桶 my-bucket-name
之前,尝试删除其中的所有数据。那么你的代码应该可以成功运行。
要删除存储桶 my-bucket-name
中的所有文件,您可以使用以下 pyspark 代码:
# see https://www.quora.com/How-do-you-overwrite-the-output-directory-when-using-PySpark
URI = sc._gateway.jvm.java.net.URI
Path = sc._gateway.jvm.org.apache.hadoop.fs.Path
FileSystem = sc._gateway.jvm.org.apache.hadoop.fs.FileSystem
# see http://crazyslate.com/how-to-rename-hadoop-files-using-wildcards-while-patterns/
fs = FileSystem.get(URI("s3a://my-bucket-name"), sc._jsc.hadoopConfiguration())
file_status = fs.globStatus(Path("/*"))
for status in file_status:
fs.delete(status.getPath(), True)
关于amazon-web-services - AWS EMR Spark : Error writing to S3 - IllegalArgumentException - Cannot create a path from an empty string,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44991550/