我有一个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")
发布于 2018-05-05 14:15:57
在引擎盖下的胶水是一种火花作业。这也是spark保存文件的方式。解决方法:保存DataFrame后,对生成的文件进行The命名。
spark作业范围内的类似quetin:Specifying the filename when saving a DataFrame as a CSV
发布于 2018-05-06 21:17:55
我想我找到解决方案了。下面是在我本地的hadoop-spark环境中工作的代码片段。需要在AWS Glue中测试
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)https://stackoverflow.com/questions/50183775
复制相似问题