Skip to main content

unique

unique is a DTL operation that deduplicates a sequence while keeping the first occurrence.

Use it after appends or extraction passes that may repeat values.

YOp

- unique:
path: tags

Parameters

ParameterTypeRequiredDescription
pathstringyesPath to the sequence to deduplicate.
bystringnoKey to deduplicate by when the sequence contains mappings. Omit for full-value equality.

Behavior

  • Requires the target path to exist.
  • Requires the target to be a sequence.
  • Keeps the first occurrence and removes later duplicates.
  • If by is provided, every item must be a mapping containing that key.
  • Equality uses canonical encoding, so mapping key order does not affect equality.

Errors

ErrorMeaning
PATH_NOT_FOUNDTarget path does not exist.
NOT_A_SEQUENCETarget is not a sequence.
INVALID_OPby was provided but an item is not a mapping or lacks that key.

Example

yops:
- unique:
path: tags

Input:

tags:
- a
- b
- a
- c
- b

Output:

tags:
- a
- b
- c