Skip to content

DE-06: Implement Coles product matching and deduplication - #296

Merged
anhvdq merged 4 commits into
DataBytes-Organisation:mainfrom
vidhipatel32:de06-coles-validation
Sep 16, 2026
Merged

anhvdq merged 4 commits into
DataBytes-Organisation:mainfrom
vidhipatel32:de06-coles-validation

Conversation

@vidhipatel32

@vidhipatel32 vidhipatel32 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements DE-06 product matching and deduplication for the Coles ETL pipeline.

Changes

  • Implemented deterministic canonical product identity generation.
  • Normalised Coles product names, brands and pack information.
  • Added ETL deduplication using:
    • raw product ID
    • canonical product key
    • source file
  • Added deterministic conflict handling using the latest recorded timestamp
    with price as the tie-breaker.
  • Preserved legitimate brand and pack-size variants.
  • Added reusable Coles validation queries.
  • Added detailed documentation covering the matching strategy,
    deduplication behaviour, limitations and validation evidence.

Validation

Coles pipeline executed successfully for:

2026-01-01 to 2026-05-04

Results:

  • Raw input rows: 232,439
  • Normalised rows: 186,723
  • Pipeline completed successfully.
  • Validation found no duplicate canonical product groups in the checked
    product identity combination.

Matching Strategy

The implementation uses deterministic matching based on normalised:

brand + product name + pack quantity + pack unit

GTIN is documented as the preferred identifier when available, but GTIN
values are not populated in the current Coles Silver dataset, so GTIN-first
matching could not be directly validated.

Near-duplicate candidates are flagged for review rather than automatically
fuzzy-merged to avoid incorrect product identity merges.

Scope

This PR is limited to the Coles implementation and its validation/documentation.

@vidhipatel32 vidhipatel32 changed the title DE-06: Add Coles matching validation queries and analysis DE-06: Implement Coles product matching and deduplication Aug 31, 2026

@anhvdq anhvdq left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your works on this PR.
Please help check and address all issues from my comments

Comment thread Documentation/DE-06_Coles_Analysis.md

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this file? Is this just for documentation or it is used anywhere?
If it's not run in the code and only use for documentation, move it to docs folder and make it MD file instead of sql
Write it as a documentation file and you can mention the code in MD file using three backtick syntax
For example:

SELECT
    COUNT(*) AS total_products,
    COUNT(gtin) AS products_with_gtin,
    COUNT(*) - COUNT(gtin) AS products_without_gtin,
    ROUND(
        100.0 * COUNT(gtin) / NULLIF(COUNT(*), 0),
        2
    ) AS gtin_coverage_percent
FROM silver.dim_products;

Comment on lines +108 to +118

CASE lower(
NULLIF(
regexp_extract(
lower(coalesce(raw_size, '')),
'^[0-9]+(?:\.[0-9]+)?\s*([a-z]+)',
1
),
''
)
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the similar changes on this file
The newline changes are redundant and create a lot of distraction / unnecessary diff view
If we don't have any actual change in the code, leave it as original and dont reformat the file

Comment on lines +122 to +170

WHEN 'kg' THEN 'kg'
WHEN 'kilo' THEN 'kg'
WHEN 'kilos' THEN 'kg'

WHEN 'ml' THEN 'ml'

WHEN 'l' THEN 'l'
WHEN 'lt' THEN 'l'
WHEN 'ltr' THEN 'l'
WHEN 'litre' THEN 'l'
WHEN 'litres' THEN 'l'
WHEN 'liter' THEN 'l'
WHEN 'liters' THEN 'l'

WHEN 'ea' THEN 'ea'
WHEN 'each' THEN 'ea'

WHEN 'pack' THEN 'pack'
WHEN 'pk' THEN 'pack'

WHEN 'm' THEN 'm'
WHEN 'metre' THEN 'm'
WHEN 'meter' THEN 'm'

ELSE NULL
END AS pack_uom,

COALESCE(
save_statement,
offer_description,

CASE
WHEN lower(coalesce(promotion_type, '')) NOT IN ('', 'everyday') THEN promotion_type
WHEN lower(coalesce(promotion_type, ''))
NOT IN ('', 'everyday')
THEN promotion_type
ELSE NULL
END,

CASE
WHEN lower(coalesce(special_type, '')) NOT IN ('', 'everyday') THEN special_type
WHEN lower(coalesce(special_type, ''))
NOT IN ('', 'everyday')
THEN special_type
ELSE NULL
END,

CASE
WHEN upper(coalesce(comparable, '')) = 'SPECIAL' THEN comparable
WHEN upper(coalesce(comparable, '')) = 'SPECIAL'
THEN comparable

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to previous comments, why do we add newlines?
Dont reformat the file

@anhvdq
anhvdq force-pushed the de06-coles-validation branch from 8127964 to a8d93b6 Compare September 16, 2026 07:41

@anhvdq anhvdq left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the changes for the issues on this ticket
Good to go now

@anhvdq
anhvdq merged commit 9f2757f into DataBytes-Organisation:main Sep 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants