如何按名称从 Glue DynamicFrame 检索字段值

Gan*_*alf 0 python amazon-web-services pyspark aws-glue

在 Spark DataFrame 中,您可以使用其名称来寻址架构中的列值,例如df['personId']- 但这种方式不适用于 Glue 的 DynamicFrame。是否有类似的方法,无需将 DynamicFrame 转换为 DataFrame,即可按名称直接访问列值?

TKN*_*TKN 5

您可以使用select_fields,请参阅 https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-crawler-pyspark-transforms-SelectFields.html

在你的情况下,它会是df.select_fields("personId")。根据您想要执行的操作,您可以将其另存为新的动态帧或仅查看数据。

new_frame = df.select_fields("personId")
new_frame.show()
Run Code Online (Sandbox Code Playgroud)