我当前的ETL体系结构如下:
s3 --> staging table --> python dataframe --> destination table
但是,目标表中的重复记录有问题:
| Time | New records (S3) | Redshift staging table (postgre) | Python DataFrame | Redshift Destination Table (postgre) | Duplicate records |
|------|------------------|----------------------------------|------------------|--------------------------------------|-------------------|
| 9am | 3 records | 3 records | 3 records | 3 records | 0 (3-3) |
| 10am | 2 records | 5 (3+2) records | 5 records | 8 (3+5) records | 3 (8-5) |
| 11am | 4 records | 9 (5+4) records | 9 records | 17 (9+8) records | 8 (17-9) |
因此,在上午11点,暂存表有9条记录,而目标表有17条记录(在上午11点,目标表中总共有8条重复记录)
如何确保目标表中的总记录与暂存表中的记录匹配
(我无法删除暂存表。现在,我正在筛选目标表以只选择唯一的记录。有更好的方法吗?)你知道吗
stage和destination表都在Postgres中,所以只需编写逻辑,将stage表中的数据与dest表中的数据进行比较,并从stage中删除dest表中已经存在的所有记录。你知道吗
https://www.postgresql.org/docs/8.1/static/functions-subquery.html
相关问题 更多 >
编程相关推荐