2

Delta live table now has the capability to do SCD Type 2 changes. But after going through this feature, I understood that this will work if I have only one new row with a new effective date. In the scenario where I have two new rows with two different effective dates, how do we handle such scenarios. For example, if I have a discount that is effective from today till next 3 months and one more discount which is effective after three months. In this case, whenever a change record comes, i will have to sort the rows to get the latest effective data and change that and not the future one

Thanks

Alex Ott
  • 80,552
  • 8
  • 87
  • 132
Rajib Deb
  • 1,496
  • 11
  • 30

2 Answers2

1

In a scenario like this, you can make a struct out of two effective dates in your data and pass that struct to the sequence by to handle the ordering for you.

Mojgan Mazouchi
  • 355
  • 1
  • 6
  • 15
0

Does those two discount have any unique key? If that is the case you can build the type2 using that. If not you can make the discount and discount end date as a key.

BobGally
  • 11
  • 2
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 21 '22 at 12:32