@Khasim_1
I tested this with a small AUTO CDC pipeline and SEQUENCE BY STRUCT() works as expected for same-timestamp ties.
Eg: In below data
Event_ts seq_id operation
12:00 seq=1 INSERT
12:10 seq=1 UPDATE
12:10 seq=2 DELETE
with sequence_by=struct("event_ts", "seq_id"), the second field is used as the tie-breaker, so (12:10, 2) is considered later than (12:10, 1).
In my test with SCD Type 1, the final target row was removed because the latest logical event was the DELETE. The source CDC table still retained all events, the target represented only the latest state.
Summary:
- Out-of-order arrival -> AUTO CDC handles this through SEQUENCE BY.
- Same timestamp ties -> use STRUCT(timestamp, secondary_sequence).
- No reliable secondary sequence from source -> add a pre-processing step: staging/dedup before AUTO CDC.
Iโd also avoid assuming that AUTO CDC gives DELETE or UPDATE any priority when their sequence values are identical. Use an explicit tie-breaker so the event order is deterministic.