【发布时间】:2021-05-14 04:46:36
【问题描述】:
所以在某些操作之后,我在 Spark DataFrame 中有一些数据,具体来说,org.apache.spark.sql.DataFrame = [_1: string, _2: string ... 1 more field]
现在当我执行df.show() 时,我得到以下输出,这是预期的。
+--------------------+--------------------+--------------------+
| _1| _2| _3|
+--------------------+--------------------+--------------------+
|industry_name_ANZSIC|'industry_name_AN...|.isComplete("indu...|
|industry_name_ANZSIC|'industry_name_AN...|.isContainedIn("i...|
|industry_name_ANZSIC|'industry_name_AN...|.isContainedIn("i...|
| rme_size_grp|'rme_size_grp' is...|.isComplete("rme_...|
| rme_size_grp|'rme_size_grp' ha...|.isContainedIn("r...|
| rme_size_grp|'rme_size_grp' ha...|.isContainedIn("r...|
| year| 'year' is not null| .isComplete("year")|
| year|'year' has type I...|.hasDataType("yea...|
| year|'year' has no neg...|.isNonNegative("y...|
|industry_code_ANZSIC|'industry_code_AN...|.isComplete("indu...|
|industry_code_ANZSIC|'industry_code_AN...|.isContainedIn("i...|
|industry_code_ANZSIC|'industry_code_AN...|.isContainedIn("i...|
| variable|'variable' is not...|.isComplete("vari...|
| variable|'variable' has va...|.isContainedIn("v...|
| unit| 'unit' is not null| .isComplete("unit")|
| unit|'unit' has value ...|.isContainedIn("u...|
| value| 'value' is not null|.isComplete("value")|
+--------------------+--------------------+--------------------+
当我尝试将数据帧作为 csv 导出到我的 S3 存储桶时,会出现问题。
我的代码是:df.coalesce(1).write.mode("Append").csv("s3://<my path>")
但是在我的 S3 路径中生成的 csv 充满了乱码或富文本。此外,执行后火花提示不会重新出现(意味着执行没有完成?)这是我的 S3 中生成的 csv 的示例屏幕截图:
我做错了什么,我该如何纠正?
【问题讨论】:
-
尝试“s3a://
” -
谢谢。这行得通。你能告诉我这里发生了什么吗?为什么使用“s3a”有效?
标签: scala csv apache-spark amazon-s3 amazon-emr