amazon-web-services - AWS EMR Spark : Error writing to S3 - IllegalArgumentException - Cannot create a path from an empty string

标签 amazon-web-services apache-spark amazon-s3 amazon-emr

我已经尝试解决这个问题很长时间了......不知道为什么我会得到这个?仅供引用,我正在 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/

相关文章:

amazon-web-services - SpotFleetRequest - 标签规范资源类型必须有一个值

node.js - 通过 SSL 提供的 Elastic Beanstalk node.js 应用程序

python - AWS Lambda 未读取环境变量

scala - 如何检查列表是否包含所有相同的值?

amazon-web-services - 在 AWS 用户名和非 identity_id 下的 S3 中的 AWS Amplify 存储

spring - 如何使用 Spring Cloud AWS 从 S3 删除文件?

amazon-s3 - s3cmd:根据扩展名搜索文件并从存储桶中删除

amazon-s3 - Spark-1.4.1 saveAsTextFile 到 S3 在 emr-4.0.0 上非常慢

json - Spark对json的异常处理

amazon-web-services - 如何检查 AWS S3 同步是否有任何更改?