You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AWS Glue 2.x调用writeFrame报错:pyWriteDynamicFrame方法不存在

Fixing pyWriteDynamicFrame Method Not Found Error in AWS Glue Job

Let's break down what's causing this error and how to fix it quickly:

The Root Cause

Looking at your error stack trace and code, you're passing a Spark DataFrame (datasource1) to sink.writeFrame(), but this method expects a Glue DynamicFrame instead. In your code, you correctly converted datasource1 to datasource2 (a DynamicFrame), but you accidentally used the wrong variable in the write call.

Corrected Code

Here's the fixed version of your code snippet:

datasource0 = glueContext.create_dynamic_frame.from_catalog(database = "my_db", table_name = "table1", transformation_ctx = "datasource0")
datasource1 = datasource0.toDF().withColumn("date", current_date().cast("string"))
# This converts the Spark DataFrame back to a Glue DynamicFrame
datasource2 = DynamicFrame.fromDF(datasource1, glueContext, "datasource2")
sink = glueContext.getSink(connection_type="s3", path="s3://my_bucket/output", enableUpdateCatalog=True)
sink.setFormat("json")
sink.setCatalogInfo(catalogDatabase='my_db', catalogTableName='table2')
# Use datasource2 (DynamicFrame) instead of datasource1 (Spark DataFrame)
sink.writeFrame(datasource2)
job.commit()

Additional Notes

  • When working with AWS Glue sinks, always ensure you're passing a DynamicFrame to writeFrame(). Spark DataFrames don't have the underlying Java methods that Glue's sink expects, which is why you got the pyWriteDynamicFrame method not found error.
  • Double-check variable names when switching between Spark DataFrames and Glue DynamicFrames—it's an easy typo to make!

内容的提问来源于stack exchange,提问作者Rax Wunter

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 22:32:42