Brahmareddy
Esteemed Contributor II

Hi Dewlap,

How are you doing today? As per my understanding, You're right to notice that apply_changes in DLT works best for one-row-per-key updates and doesn't fit well when you need to replace multiple rows for the same key, especially after exploding arrays. A good workaround is to break this into two steps: first, write your transformed and exploded records into a staging table or view; then, in the next step, delete all existing records from the target table that match the incoming keys and insert the new rows. This "overwrite-by-key" pattern gives you better control and is more suited for your use case. While DLT doesn’t have a native function for this, handling it in a custom logic with a staging layer (especially in a silver-to-gold setup) is a practical and often-used solution. If you're running in streaming mode, you might also consider using a foreachBatch block to manage the deletes and inserts safely. Let me know if you'd like help with a code example.

Regards,

Brahma