首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将aws glue文件输出写入特定名称

如何将aws glue文件输出写入特定名称
EN

Stack Overflow用户
提问于 2018-05-05 06:20:46
回答 2查看 8.4K关注 0票数 2

我有一个aws作业,它连接两个Aurora表,并将输出以json格式写入/接收到s3存储桶中。这项工作如预期的那样工作得很好。默认情况下,输出文件以这种名称格式/模式“s3 -123456789-part-r-00000”写入hadoop,后台是它在Hadoop群集中运行的pyspark代码,因此文件名类似hadoop

现在,我的问题是如何编写具有特定名称的文件,如"Customer_Transaction.json“,而不是”run-*-part*“

我尝试转换为DataFrame,然后编写为json,如下所示,但不起作用

customerDF.repartition(1).write.mode("overwrite").json("s3://bucket/aws-glue/Customer_Transaction.json")

EN

回答 2

Stack Overflow用户

发布于 2018-05-05 14:15:57

在引擎盖下的胶水是一种火花作业。这也是spark保存文件的方式。解决方法:保存DataFrame后,对生成的文件进行The命名。

spark作业范围内的类似quetin:Specifying the filename when saving a DataFrame as a CSV

票数 0
EN

Stack Overflow用户

发布于 2018-05-06 21:17:55

我想我找到解决方案了。下面是在我本地的hadoop-spark环境中工作的代码片段。需要在AWS Glue中测试

代码语言:javascript
复制
Path = sc._gateway.jvm.org.apache.hadoop.fs.Path
FileSystem = sc._gateway.jvm.org.apache.hadoop.fs.FileSystem
FileStatus = sc._gateway.jvm.org.apache.hadoop.fs.FileStatus

fs = FileSystem.get(sc._jsc.hadoopConfiguration())
srcpath = Path("/user/cloudera/IMG_5252.mov")
dstpath = Path("/user/cloudera/IMG_5252_123.mov")
if(fs.exists(srcpath) == False):
    print("Input path does not exists")
else:
    #print("Path exists")
    srcpath.rename(srcpath,dstpath)
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50183775

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档