Sumator
Type:
sumator• Category:flow• Tags:join,merge,data
Description
Join two lists of dicts by key
Parameters
| Name | Type | Description | Required | Default |
|---|---|---|---|---|
leftExpr | string | Expr -> list[dict] (left) or directly list | no | |
rightExpr | string | Expr -> list[dict] (right) or directly list | no | |
key | string | Common key present in both dicts | no | |
joinType | string | Join type | no | "inner" |
conflictStrategy | string | Conflict: prefer_left / prefer_right / rename_right (suffix _r) | no | "prefer_left" |
Help
Overview
The Join Lists of Dictionaries worker merges two collections of dictionary objects based on a common key. It can perform inner, left, right, or full outer joins and resolves key conflicts according to a configurable strategy. This worker is useful when you need to combine market‑data snapshots, trade‑record lists, or any other tabular data represented as lists of dictionaries.
Inputs
- leftExpr – A string expression that evaluates to the left‑hand list of dictionaries, or the list itself.
- rightExpr – A string expression that evaluates to the right‑hand list of dictionaries, or the list itself.
- key – The name of the field that exists in every dictionary of both lists and will be used as the join key.
- joinType – The type of join to perform. Accepted values are
inner(default),left,right, andfull. - conflictStrategy – Determines how to handle fields that have the same name in both dictionaries but different values. Options are:
prefer_left(default) – Keep the left‑hand value.prefer_right– Keep the right‑hand value.rename_right– Preserve both values, renaming the right‑hand field with a_rsuffix.
Example Usage
Assume you have two lists of market quotes:
- leftList =
[{"symbol":"AAPL","price":150},{"symbol":"MSFT","price":300}] - rightList =
[{"symbol":"AAPL","volume":10000},{"symbol":"GOOG","volume":5000}]
To join them on the symbol field, keeping all matching rows and preferring the left‑hand price when a conflict occurs, you would configure the worker as follows:
leftExpr = leftList
rightExpr = rightList
key = "symbol"
joinType = "inner"
conflictStrategy = "prefer_left"
The resulting list would be:
[{"symbol":"AAPL","price":150,"volume":10000}]
Only the entry for AAPL appears because it is the only symbol present in both input lists, and the price field from the left list is retained while the volume field from the right list is added.