03-deduplication

Deduplicate Silver table business keys by timestamp before Delta MERGE.

5|6|Updated Jan 26, 2026
One-click install
npx skills add https://github.com/databricks-solutions/vibe-coding-workshop-template --skill 03-deduplication
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: 03-deduplication
Source: https://github.com/databricks-solutions/vibe-coding-workshop-template/tree/main/data_product_accelerator/skills/gold/pipeline-workers/03-deduplication
Command: npx skills add https://github.com/databricks-solutions/vibe-coding-workshop-template --skill 03-deduplication

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill addresses the critical issue of duplicate business keys in data being merged into the Gold layer, preventing common Delta Lake errors and ensuring data integrity.

Core Features & Use Cases

  • Standardized Deduplication: Implements a robust, ordered deduplication pattern before MERGE operations.
  • Error Prevention: Avoids DELTA_MULTIPLE_SOURCE_ROW_MATCHING_TARGET_ROW_IN_MERGE errors by ensuring source uniqueness.
  • Use Case: When merging customer data from Silver to Gold, if the Silver table contains multiple records for the same customer due to streaming or CDC, this skill ensures only the latest record is used for the merge, preventing failures.

Quick Start

Use this skill to deduplicate the silver_customer_dim table on the 'customer_id' business key before merging into the gold_customer_dim table.

Frequently Asked Questions about 03-deduplication

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent duplicate source key errors during a Delta Lake MERGE operation?▼

To prevent duplicate source key errors in a Delta Lake MERGE, apply a deduplication pattern that orders source data by timestamp descending and drops duplicates on the business key before merging.

Why does my Gold layer MERGE fail with a multiple source row matching target row error?▼

A Gold layer MERGE fails with a multiple source row matching error because the Silver table contains duplicate business keys from incremental streaming or CDC, requiring source deduplication before the MERGE.

What is the best way to deduplicate Silver table records before merging into the Gold layer?▼

The best way to deduplicate Silver table records is to order the data by timestamp descending and then drop duplicates on the business key, ensuring only the latest record merges into the Gold layer.

How do I handle duplicate business keys in Delta Lake caused by CDC or SCD Type 2?▼

Handle duplicate business keys from CDC or SCD Type 2 by applying a standardized deduplication pattern that sorts by timestamp descending and removes duplicates before performing the Delta MERGE.

Does this deduplication pattern work for incremental DLT streaming data?▼

Yes, this deduplication pattern works for incremental DLT streaming data by ordering records by timestamp descending and dropping duplicates on the business key to ensure source uniqueness before merging.

When do I need to deduplicate source data before a Delta MERGE?▼

You need to deduplicate source data before a Delta MERGE when Silver tables contain multiple records for the same business key due to streaming, CDC, SCD Type 2, or multiple batch loads.