03-deduplication

Deduplicate Silver DataFrames before Delta MERGE into Gold tables.

1|Updated Jan 22, 2026
One-click install
npx skills add https://github.com/prashsub/vibe_coding_lakehouse_starter_repo --skill 03-deduplication-prashsub
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: 03-deduplication
Source: https://github.com/prashsub/vibe_coding_lakehouse_starter_repo/tree/main/data_product_accelerator/skills/gold/pipeline-workers/03-deduplication
Command: npx skills add https://github.com/prashsub/vibe_coding_lakehouse_starter_repo --skill 03-deduplication-prashsub

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill prevents critical DELTA_MULTIPLE_SOURCE_ROW_MATCHING_TARGET_ROW_IN_MERGE errors that occur when merging data from Silver to Gold tables, ensuring data integrity and smooth pipeline operations.

Core Features & Use Cases

  • Standardized Deduplication: Implements a robust, repeatable pattern for removing duplicate records from Silver DataFrames before they are merged into Gold tables.
  • Handles Common Duplication Sources: Addresses duplicates arising from DLT streaming, CDC, SCD Type 2, and multiple batch loads.
  • Use Case: When ingesting customer data from Silver to Gold, this skill ensures that only the latest version of each customer record is merged, preventing errors and maintaining a clean Gold dimension table.

Quick Start

Use the 03-deduplication 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 fix the DELTA_MULTIPLE_SOURCE_ROW_MATCHING_TARGET_ROW_IN_MERGE error?▼

To fix the DELTA_MULTIPLE_SOURCE_ROW_MATCHING_TARGET_ROW_IN_MERGE error, deduplicate the source DataFrame on the business key using .orderBy(col("processed_timestamp").desc()).dropDuplicates() before executing the Delta MERGE operation.

Why does my Delta MERGE fail when loading Silver to Gold tables?▼

Your Delta MERGE fails because the Silver table contains duplicate business keys from incremental DLT streaming or multiple batch loads, violating the single-row match requirement for target updates.

How do I deduplicate Silver DataFrames before merging into Gold tables?▼

To deduplicate Silver DataFrames before merging into Gold tables, sort the records by the processed_timestamp in descending order and apply dropDuplicates on the business key to retain only the latest version.

Does this deduplication pattern handle duplicate records from CDC and SCD Type 2 tracking?▼

Yes, this deduplication pattern handles duplicate records generated by CDC patterns, SCD Type 2 tracking, and multiple batch loads by standardizing the deduplication logic before the Delta MERGE operation.

What is the best way to prevent duplicate source key errors in Delta Lake Gold layer merges?▼

The best way to prevent duplicate source key errors in Gold layer merges is to implement a standardized deduplication pattern that filters duplicates from the Silver DataFrame before merging data into the Gold dimension table.

Can I use this deduplication pattern for DLT streaming pipelines?▼

Yes, you can use this deduplication pattern for DLT streaming pipelines to resolve duplicate business keys introduced during incremental data ingestion before they cause Gold layer merge conflicts.