微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

AWS Glue create_dynamic_frame from_catalog 返回不在架构中的列

如何解决AWS Glue create_dynamic_frame from_catalog 返回不在架构中的列

嗨,从今天起,我遇到了胶水的有线问题。我的数据是这样的结构

/year=2021/month=5/day=1/task_id=k2j34h5w4hrkj/type=Meta/ => Meta_file /year=2021/month=5/day=1/task_id=k2j34h5w4hrkj/type=data/ => data_file

我使用 glue Crawler 和排除模式成功地抓取了两条路径,以便获得元数据和数据表。模式看起来正是我想要的样子。当使用 AWS 提供的 docker 镜像在本地测试时,一切正常,并且仍然正常工作。但是,在 AWS 中运行 glue 作业时,我发现两种架构混合在一起。

datasource0 = glueContext.create_dynamic_frame.from_catalog(
    database = "raw-db",table_name = "ih_data",transformation_ctx = "datasource0",push_down_predicate = "(year='2021' and month='5' and day='4' and task_id='604bb2cb198325001caf6198')",)

datasource1 = glueContext.create_dynamic_frame.from_catalog(
    database = "raw-db",table_name = "ih_Meta",transformation_ctx = "datasource1",)


# transform to spark dataframes
data = datasource0.toDF()
Meta = datasource1.toDF()
data.printSchema()
Meta.printSchema()

数据和元数据都具有相同的列,它们是目录中两种模式的混合。我检查了底层文件,它们与我在目录中看到的内容以及从 docker 容器运行脚本时得到的内容相匹配。真正连接的事情是它在本地执行时可以完美运行,即使它使用相同的目录和相同的 s3 存储桶。也许你们中的一个可以为我指明正确的方向?

谢谢

更新: 这是模式的简化版本,我不会将它们作为一个整体发布,因为它们非常广泛:

数据架构:

year: (string) Partition (0)
month: (string) Partition (1)
day: (string) Partition (2)
task_id: (string) Partition (3)
type: (string) Partition (4)
data_value_0: int
data_value_1: int
data_value_2: float

元架构:

year: (string) Partition (0)
month: (string) Partition (1)
day: (string) Partition (2)
task_id: (string) Partition (3)
type: (string) Partition (4)
Meta_value_0: int
Meta_value_1: int

这些也是我在本地使用 glueContext.create_dynamic_frame.from_catalog 查询目录时看到的模式。

但是,当我在 AWS 上运行我的脚本时,两者的架构如下所示:

year: (string) Partition (0)
month: (string) Partition (1)
day: (string) Partition (2)
task_id: (string) Partition (3)
type: (string) Partition (4)
data_value_0: int
data_value_1: int
data_value_2: float
Meta_value_0: int
Meta_value_1: int

我只是对本地 docker 映像的行为非常不同感到困惑。在 AWS 上使用 push_down_predicate="(type='data')" 作为快速修复。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。