apache-spark - Spark,为什么删除列会导致 Spark 作业失败?
问题描述
在 Spark 2.0 中,我正在运行一个 pyspark 作业,我从表中读取数据,添加一些列,其逻辑基于 30 天的数据窗口,然后我使用df.createOrReplaceTempView
后续spark.sql(create table as select * from ...)
在 HDFS 中创建表。
该作业成功运行并在 HDFS 中创建了一个表。但是,我不需要我刚刚在数据框中创建的所有列。我只需要一半的新列,因此我添加了一些逻辑来删除我不需要的列(所有这些将被删除的列都是最近创建的)。当我运行 drop `df = df.select([c for c in df.columns if c not in ('a','b','d','e')]) 时,火花作业现在失败了!
错误:Job aborted due to stage failure: Task 139 in stage 1.0 failed 4 times, most recent failure: Lost task 139.3 in stage 1.0 (TID 405, myhost, executor 197): ExecutorLostFailure (executor 197 exited caused by one of the running tasks) Reason: Container marked as failed: container_111 on host: myhost. Exit status: 143. Diagnostics: Container killed on request. Exit code is 143
解决方案
您可以使用 .drop("colname") 从数据框中删除列。
df1=df.drop("a","b","c","d")
希望它可以帮助你。
推荐阅读
- javascript - 有没有办法使用节点将较小的 PDF 文件插入到较大的 PDF 页面中?
- javascript - 将旋转元素的中心移动到光标
- javascript - useState 向对象添加属性只剩下最后一个属性
- gradle - 错误:尝试在 jitpack 上构建我的 gradle 项目时未找到构建工件
- java - 有什么方法可以根据我们的输入链接到该网站?
- laravel - 创建用户时,给role_id分配UUID
- bash - Docker 文件没有 /bin/bash 目录
- python-3.x - 同时调度或运行线程
- xlwings - xlwings UDF:返回多个输出
- angular - 如何阻止来自 AWS Beanstalk 应用程序(Angular)的 Web 抓取或爬取 Web 内容(图像)?