【发布时间】:2022-01-13 06:49:00
【问题描述】:
我正在尝试使用 pyspark 在 SQL 中进行类似合并的功能。我有以下 2 个数据框作为源和目标。
source
id,name,city
1,abc,pune
2,xyz,noid
我希望在目标数据框下方有 2 个额外的列
id,name,city,createdAt,lastupdatedAt
1,abc,pune,current_time,current_time
2,xyz,noida,current_time,current_time
这里的键列是id 字段。因此,如果源数据框有任何变化,我的目标数据框应该反映相同。如果源有更新的数据,目标字段createdAt 保持不变,我们更新了lastupdatedAt 字段。如果源有新数据,则应更新目标字段createdAt,而lastupdatedAt 字段保持不变。
有人可以帮我解决逻辑,或者如果需要进行任何设计更改以实现此要求。
提前致谢, 瓦西姆
【问题讨论】:
标签: sql python-3.x apache-spark pyspark