我对AWS Glue还是很陌生,但仍在尝试解决问题,我尝试搜索以下内容,但找不到答案...
有人知道如何在AWS Glue作业脚本中遍历DynamicFrame吗?
例如,我正在尝试执行以下操作:
datasource0 = glueContext.create_dynamic_frame.from_catalog(
database = "...",
table_name = "...",
transformation_ctx = "datasource0")
for r in datasource0:
print(r)
但是收到以下错误:
'DynamicFrame' object is not iterable
Traceback (most recent call last):
TypeError: 'DynamicFrame' object is not iterable
答案 0 :(得分:1)
将Glue的DynamicFrame转换为Spark的DataFrame并使用foreach函数来迭代行:
def f(row):
print(row.name)
...
datasource0.toDF().foreach(f)