scala - 在 s3 存储桶中加载时出现 SparkOutOfMemoryError
问题描述
我有一个数据框并写入 S3 存储桶目标位置。在 Coalesce 用于加载数据和获取 SparkOutOfMemoryError 的代码中。当前的代码 Coalesce 一直在使用多个项目,并且看到很多解决方案建议重新分区,它对我有用。即使它的记录为零,coalesce 也不起作用。有没有其他方法可以在不更改重新分区的情况下解决此问题?
代码:
empsql = 'Select * From Employee'
df = spark.sql(empsql) ##Spark is configured
df.coalesce(2).write.mode('overwrite').format("parquet").option("delimiter",'|').save(s3_path, header = True)
错误:
org.apache.spark.SparkException:写入行时任务失败。在 org.apache.spark.sql.execution.datasources.FileFormatWriter$.org$apache$spark$sql$execution$datasources$FileFormatWriter$$executeTask 在 org.apache.spark.sql.execution.datasources.FileFormatWriter$$anonfun$ write$1.apply at org.apache.spark.sql.execution.datasources.FileFormatWriter$$anonfun$write$1.apply at org.apache.spark.scheduler.ResultTask.runTask at org.apache.spark.scheduler.Task.run at org.apache.spark.executor.Executor$TaskRunner$$anonfun$10.apply at org.apache.spark.util.Utils$.tryWithSafeFinally at org.apache.spark.executor.Executor$TaskRunner.run at java.util. concurrent.ThreadPoolExecutor.runWorker at java.util.concurrent.ThreadPoolExecutor$Worker.run at java.lang.Thread.run 原因:org.apache.spark.memory。
解决方案
不确定这是否适合您,但请尝试这样做
df.coalesce(2,shuffle=true).write.mode('overwrite').format("parquet").option("delimiter",'|').save(s3_path, header = True)
shuflle =true 将添加一个随机播放步骤。分区将并行执行。该行为类似于使用重新分区
推荐阅读
- wordpress - 403 Forbidden while proxy pass using Nginx
- asp.net - OAuthAuthorizationProvide vs Aspnet.security.openinconnect
- excel - VBA删除文件夹,无论任何用户
- mysql - 我如何在 xamp 中启动 mysql 的管理面板,因为它显示了致命错误?
- java - 硒元素并不总是变得可点击
- php - 当用户在CKeditor的源代码中留下一些标签或引号时如何解决?
- powershell - PowerShell 使用由 DNS 别名屏蔽的服务器名称停止和启动服务
- javascript - glyphicon 能够使用@click
- angularjs - 小数点后位数过多
- java - Angular4 switchMap