DocsWorkflowsComponentsDatadata:list:union

data:list:union

Coalesces two lists into one item per key, preferring the first list. Items pair up through the configured key paths, A's item is taken wherever a key appears in both, and B fills the keys A has nothing for. That is the link a precedence chain is built from, so a policy such as approved over published over base is a union of a union rather than a query that has to know the policy. Neither list may repeat a key, and nothing is written anywhere.

Options

NameTypeDescription
a[]map[string]anyThe preferred list, whose item wins wherever a key appears in both
b[]map[string]anyThe filling list, whose item is taken only for a key A does not carry
keys[]stringThe dotted paths whose values identify the same item in both lists

Outputs

NameTypeDescription
items[]map[string]anyThe union, in A's order followed by the keys only B carries
countsListUnionCountsThe size of the union and each side's contribution
  ↳ itemsint
  ↳ from_aint
  ↳ from_bint

Example

name: Resolve a translation by precedence
actions:
  - name: stable_head
    component: data:list:union
    vars:
      a: "{{ var.approved }}"
      b: "{{ var.published }}"
      keys: [key_id, variant]
  - name: stable
    component: data:list:union
    vars:
      a: "{{ stable_head.items }}"
      b: "{{ var.base_values }}"
      keys: [key_id, variant]

outputs:
  items: "{{ stable.items }}"
  counts: "{{ stable.counts }}"