surfaceentity resolutiongolden_record
Entity Resolutionaggregate · returns varchar

GOLDEN_RECORD

Merge duplicate records into a composite golden record

Per-group — reads the whole group in one call.

entity-resolutionllmtext

Syntax

GOLDEN_RECORD({{ records }})

Arguments

nametypedescription
recordsVARCHARJSON record or struct to aggregate

About

Merge a group of duplicate or related records into one "golden" composite by choosing the best value for each field — the most complete, most recent, and highest-quality option across the group. Useful after a fuzzy join or dedupe pass where you have multiple representations of the same entity (customer, product, organization) and need a single canonical row for downstream analytics, exports, or system-of-record updates. Selection priority per field: completeness first (prefer a populated value over a null or empty), then freshness (prefer a more recent source where that's apparent), then overall quality. Prefer MERGE_RECORDS when you want an explicit conflict-resolution strategy per field. Prefer BEST when you just need to pick one whole value, not merge piece by piece.

Examples

Creates golden record from duplicate customer records

WITH
  test_data AS (
    SELECT
      *
    FROM
      (
        VALUES
          (
            '{"name": "JOHN SMITH", "email": "john@gmail.com", "phone": null}'
          ),
          (
            '{"name": "John Smith", "email": null, "phone": "(555) 123-4567"}'
          ),
          (
            '{"name": "John Q. Smith", "email": "john.smith@gmail.com", "phone": "555-123-4567"}'
          )
      ) AS t (record)
  )
SELECT
  GOLDEN_RECORD (record)
FROM
  test_data

Nearby rabbit holes

same domain
Climb back to The Looking Glass