I have an AWS Redshift table looking like this:
id, id_aw_sk, id_ai_sk, snapshot_date, update_timestamp
3278059021, 3197624, 173642, today-1, today
3278059021, 3197624, 173642, today-2, today-1
3278059021, 3197624, 173642, today-3, today-2
3278059021, 3197624, 173642, today-4, today-3
etc.
3278059021, 3224904, 173642, date in past -1, date in past
This table contains snapshot on every day, to see changes in some other columns. if there's a change id_aw_sk would be different than the previous one. What seems to be the issue is that I have some date gaps for some rows, accidently deleted rows. As i can't retrieve those, I would like to "create" them by finding gaps in dates.
I am not sure how to do this. Please, help?
I understand that i should firstly find the gaps and for each row i would use lead function to update values from current (known) rows.
e.g. i have dates for 3278059021 where id_aw_sk was 3224904, but i have gaps for dates between 16th March 2021 until 11th April 2021 for id_aw_sk 3197624. I know that all rows between those dates haven't changed. I only need to populated gaps with first known data (from 11th April) as rows from 16th March and later are the same even now.
I hope that I explained it okay :) Thanks upfront for your help.