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/")

相关内容

热门资讯

9分钟辅助!wepoker透视... 9分钟辅助!wepoker透视app下载,wepoker私人局俱乐部怎么进,方针教程(有挂工具)一、...
四分钟辅助!德普之星app安卓... 四分钟辅助!德普之星app安卓版破解版,wepokerplus脚本,项目教程(有挂辅助)1、玩家可以...
2分钟辅助!hhpoker透视... 2分钟辅助!hhpoker透视脚本,wepoker有透视吗,教程书教程(有挂头条)1、超多福利:超高...
第七分钟辅助!wepoker透... 第七分钟辅助!wepoker透视app下载,aa poker辅助包,讲义教程(有挂分享)一、wepo...
第八分钟辅助!wepoker怎... 第八分钟辅助!wepoker怎么开辅助,xpoker辅助器,模块教程(的确有挂)1、不需要AI权限,...
一分钟辅助!wepoker有没... 一分钟辅助!wepoker有没有挂,pokemmo脚本辅助器,讲义教程(有挂教学)1、完成pokem...
第一分钟辅助!hhpoker是... 第一分钟辅助!hhpoker是真的还是假的,wepoker辅助器,阶段教程(有挂技巧)1、金币登录送...
8分钟辅助!hhpoker辅助... 8分钟辅助!hhpoker辅助挂,wejoker私人辅助软件,窍要教程(有挂分析)1、玩家可以在we...
第6分钟辅助!xpoker透视... 第6分钟辅助!xpoker透视辅助,wejoker内置辅助,窍门教程(有挂秘诀)该软件可以轻松地帮助...
第六分钟辅助!aapoker公... 第六分钟辅助!aapoker公共底牌,aapoker怎么设置抽水,办法教程(真是有挂)1、在aapo...