AnalyticsCreator Docs Preview

Understand primary-key deduplication

On this page
  1. Example 1: a surrogate key preserves history versions
  2. Example 2: no surrogate-key column
  3. Verify the generated procedure

These synthetic examples explain key selection and expected results. They have not been executed against Demo_Northwind AI. Use a disposable development destination and review its constraints before executing generated processing.

Example 1: a surrogate key preserves history versions

Assume HIST_ID_FIELDNAME is SATZ_ID, and the source transformation contains that column. The following rows are in the destination when cleanup starts:

SATZ_ID EmployeeID Label
101 7 Earlier history version
102 7 Later history version
102 7 Duplicate of version 102 with different attributes
201 8 Another employee

Cleanup partitions by SATZ_ID, even if EmployeeID is marked as a primary-key column in source metadata. The expected result is three rows: 101, one arbitrary 102 row, and 201. Employee 7 still has two history versions. Do not assert which label survives for 102.

Example 2: no surrogate-key column

If the configured surrogate-key column is absent and AccountID is the source primary key, these destination rows form two groups:

AccountID Label
10 Earlier label
10 Later label
20 Single label

Cleanup leaves one arbitrary row for 10 and the row for 20. With a composite PK, compare the complete key tuple instead. Without either a surrogate key or PK metadata, the option is unavailable.

Verify the generated procedure

  1. Confirm the configured surrogate-key name and the source transformation's columns and PK metadata.
  2. Choose a generated persisting mode, enable Remove duplicates, and save.
  3. Inspect Procedure: PARTITION BY must use the surrogate key alone when present, otherwise the source PK columns.
  4. Check that the cleanup targets the final destination once, after loading and immediately before commit. Full replacement may use a replacement table earlier in the load.
  5. Confirm the source is read directly: no #AC_PersistSource copy is generated.
  6. Deploy and execute only in the permitted test environment. Check row counts by the actual duplicate key, and verify that different history-version keys survive.

Test all applicable mode choices separately. Historical and incremental modes have date/watermark prerequisites; enabling cleanup does not override them. Manual SQL is not rewritten.

If loading fails before cleanup because of duplicate source keys, the final DELETE has not run. Do not use this example as evidence that Remove duplicates makes every conflicting source valid for MERGE or constrained INSERT.

Remove duplicates reference

Search documentation