AWSGlue数据目标Upsert生成异常
创始人
2024-09-25 16:30:43
0

如果使用AWS Glue Upsert作为数据目标,可能会遇到以下错误:

An error occurred while calling o199.pyWriteDynamicFrame. org.apache.spark.SparkException: Job aborted due to stage failure: Task 256 in stage 11.0 failed 4 times, most recent failure: Lost task 256.3 in stage 11.0 (TID 28195, ip-x-x-x-x.ec2.internal, executor 64): com.amazonaws.services.s3.model.AmazonS3Exception: IncompleteRequest: The request was aborted because it contains a null byte in the payload either before or after the XML data. For more information, see the MinIO logs.

为了修复这个问题,需要更新AWS Glue Job的Python脚本,以使用AWS Glue下游的S3 Target替代Upsert Target。请按照以下步骤操作:

1.打开AWS Glue Job的Python脚本。 2.在导入文本中添加以下代码:

from awsglue.dynamicframe import DynamicFrame
from awsglue.utils import getResolvedOptions

args = getResolvedOptions(sys.argv, ['JOB_NAME'])
job_name = args['JOB_NAME']

# 函数将数据写入S3并返回新的DynamicFrame
def write_to_s3(dynamic_frame, file_format, output_location):
    glue_context.write_dynamic_frame.from_options(
        frame=dynamic_frame,
        connection_type="s3",
        connection_options={
            "path": output_location,
            "compression": "gzip",
            "partitionKeys": []
        },
        format=file_format
    )
    return DynamicFrame.from_options(
        frame=dynamic_frame,
        connection_type="s3",
        connection_options={
            "path": output_location,
            "partitionKeys": []
        },
        format=file_format
    )
  1. 使用以下代码替换原来的写入代码:
df3 = DynamicFrame.fromDF(df_merged_to_1, glueContext, "nested")

#将整合的数据写入S3。
write_to_s3(df3, args["file_format"], "s3://my-s3-bucket/path/to/output/")

相关内容

热门资讯

关于!微信微乐自建房辅助工具,... 关于!微信微乐自建房辅助工具,微乐家乡麻将自建房辅助app(开挂自建房)方法1)微乐家乡麻将自建房辅...
大家学习交流!微信卡五星辅助器... 大家学习交流!微信卡五星辅助器,微乐小程序免费黑科技(开挂自建房)方法1、很好的工具软件,可以解锁游...
三分钟了解!微乐微信自建房辅助... 三分钟了解!微乐微信自建房辅助工具插件,微乐家乡麻将自建房辅助app(开挂自建房)工具1、三分钟了解...
一分钟教会你!微乐家乡麻将自建... 一分钟教会你!微乐家乡麻将自建房辅助app,微乐自建房脚本免费入口(开挂自建房)方法1、用户打开应用...
分享实测!微信微乐自建房辅助工... 分享实测!微信微乐自建房辅助工具,微乐自建房脚本免费入口(开挂自建房)器1、起透看视 微信微乐自建房...
重大通报!微乐自建房辅助工具脚... 重大通报!微乐自建房辅助工具脚本,微乐小程序免费黑科技(开挂自建房)app微乐自建房辅助工具脚本破解...
如何分辨真伪!微乐微信自建房辅... 如何分辨真伪!微乐微信自建房辅助工具插件,微乐小程序免费黑科技(开挂自建房)技巧1、微乐微信自建房辅...
我来教教你!微乐自建房辅助工具... 我来教教你!微乐自建房辅助工具挂,微乐家乡麻将自建房辅助app(开挂自建房)工具1、玩家可以在微乐家...
重大来袭!微乐自建房辅助工具神... 重大来袭!微乐自建房辅助工具神器,微乐小程序免费黑科技(开挂自建房)器1、游戏颠覆性的策略玩法,独创...
带你了解!微信卡五星辅助器,微... 带你了解!微信卡五星辅助器,微乐自建房脚本免费入口(开挂自建房)方法1、带你了解!微信卡五星辅助器,...