AWS Glue 最大和转换行

问题描述 投票:0回答:1

我正在尝试从源存储桶 S1 加载使用 AWSglue 创建的表之一中的数据。

源存储桶有 4 列

( session_id, Date, type, action )
,其值如下。购买交易持续了 1 分钟,我们得到了 2 条相同的记录。在某些情况下,我们没有得到最终记录

session_id, Date, type, action
1, 01jan20 10:00, purchase, start
1, 01jan20 10:01, Purchase, End
1, 02jan20 11:01, bal, start 
1, 02jan20 11:05, bal, end 
2, 02jan20 11:10, bal, start 

我有目标表,我想在其中插入这些记录。它具有以下结构。

id, startdt, enddt, duration_spent_seconds, action
1 01jan20 10:00, 01jan20 10:01, 60, Purchase
1 01jan20 11:01, 01jan20 11:05, 240, bal
2 01jan20 11:10, , , Bal

我正在尝试 AWSglue,并且希望将目标表/结果存储到 S3。

有人可以帮助我详细了解如何实现这一目标吗?

如果我能开始的话那就太好了

amazon-web-services amazon-s3 aws-glue amazon-athena
1个回答
0
投票

您应该能够使用 dynamicFramesboto3 从 s3 读取和写入 csv 文件。无论哪种方式,您可能希望使用 apache Spark dataFrames 来处理到所需模式的转换。

Boto3 会直接将数据作为数据帧读取,而您需要使用

df = dynamicFrame.toDF()
将动态帧转换为数据帧。

© www.soinside.com 2019 - 2024. All rights reserved.