surfaceentity resolutionmerge_records
Entity Resolutionaggregate · returns varchar

MERGE_RECORDS

Merge records with an explicit conflict-resolution strategy

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

entity-resolutionllmtext

Syntax

MERGE_RECORDS({{ records }})
MERGE_RECORDS({{ records }}, '{{ strategy }}')

Arguments

nametypedescription
recordsVARCHARJSON records to merge
strategyVARCHARStrategy: best_quality, prefer_recent, prefer_first, prefer_longest, unanimous_only

About

Merge a group of records into one, using an explicit conflict- resolution strategy. More controllable than GOLDEN_RECORD when you need to dictate how collisions get resolved — for example, always prefer the newest source, always prefer the longest string, always union list-valued fields rather than picking one. Useful in data-integration pipelines where the merge policy is a business decision (e.g., "customer records always prefer the CRM value", "product attributes always prefer the most recent feed") rather than a quality heuristic. Supported strategies include `best_quality` (the default), plus named strategies tailored to merge behavior. For automatic quality-driven merges without a policy spec, reach for GOLDEN_RECORD instead.

Examples

Merges company records using best quality strategy

WITH
  test_data AS (
    SELECT
      *
    FROM
      (
        VALUES
          ('{"name": "Acme Corp", "address": "123 Main St"}'),
          (
            '{"name": "ACME Corporation", "phone": "555-1234"}'
          ),
          (
            '{"name": "Acme", "address": "123 Main Street", "website": "acme.com"}'
          )
      ) AS t (record)
  )
SELECT
  MERGE_RECORDS (record, 'best_quality')
FROM
  test_data

Nearby rabbit holes

same domain
Climb back to The Looking Glass