You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/concepts/models/model_kinds.md
+16-16Lines changed: 16 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -626,12 +626,7 @@ TABLE db.menu_items (
626
626
627
627
A hard delete is when a record no longer exists in the source table. When this happens,
628
628
629
-
If `invalidate_hard_deletes` is set to `true` (default):
630
-
631
-
*`valid_to` column will be set to the time when the SQLMesh run started that detected the missing record (called `execution_time`).
632
-
* If the record is added back, then the `valid_to` column will remain unchanged.
633
-
634
-
If `invalidate_hard_deletes` is set to `false`:
629
+
If `invalidate_hard_deletes` is set to `false` (default):
635
630
636
631
*`valid_to` column will continue to be set to `NULL` (therefore still considered "valid")
637
632
* If the record is added back, then the `valid_to` column will be set to the `valid_from` of the new record.
@@ -641,13 +636,18 @@ When a record is added back, the new record will be inserted into the table with
641
636
* SCD_TYPE_2_BY_TIME: the largest of either the `updated_at` timestamp of the new record or the `valid_from` timestamp of the deleted record in the SCD Type 2 table
642
637
* SCD_TYPE_2_BY_COLUMN: the `execution_time` when the record was detected again
643
638
644
-
One way to think about `invalidate_hard_deletes` is that, if enabled, deletes are most accurately tracked in the SCD Type 2 table since it records when the delete occurred.
639
+
If `invalidate_hard_deletes` is set to `true`:
640
+
641
+
*`valid_to` column will be set to the time when the SQLMesh run started that detected the missing record (called `execution_time`).
642
+
* If the record is added back, then the `valid_to` column will remain unchanged.
643
+
644
+
One way to think about `invalidate_hard_deletes` is that, if `invalidate_hard_deletes` is set to `true`, deletes are most accurately tracked in the SCD Type 2 table since it records when the delete occurred.
645
645
As a result though, you can have gaps between records if the there is a gap of time between when it was deleted and added back.
646
-
If you would prefer to not have gaps, and a result consider missing records in source as still "valid", then you can set `invalidate_hard_deletes` to `false`.
646
+
If you would prefer to not have gaps, and a result consider missing records in source as still "valid", then you can leave the default value or set `invalidate_hard_deletes` to `false`.
647
647
648
648
### Example of SCD Type 2 By Time in Action
649
649
650
-
Lets say that you started with the following data in your source table:
650
+
Lets say that you started with the following data in your source table and `invalidate_hard_deletes` is set to `true`:
0 commit comments