Merge Lists
Blend two input lists into one using a shared identifier.
Use Case
You're faced with two separate lists of data that need to be combined based on a common attribute. You require a merging method that mimics SQL JOINs.
Overview
The Merge Lists
transform equips you with the functionality to effectively merge two lists into one. By aligning items based on a shared key attribute and allowing for three types of merging strategies (inner
, left
, and outer
), it enhances your data analysis and manipulation capabilities.
Parameters
Here are the parameters you have available to you within the action, and their descriptions:
Parameter | Description | Required |
---|---|---|
Merge Method | Choose the strategy to merge the lists. Options are | |
First List | Enter the first list for the merging process. | |
First List's Key | Identify the key attribute for matching items in the first list. | |
Second List | Enter the second list to be merged with the first one. | |
Second List's Key | Identify the key attribute for matching items in the second list. |
Usage
Input Lists
For this transform, we will want to provide the action two lists and their corresponding key's to be used for mapping the comparisons. Let's use the below for our examples:
List 1:
List 2:
Merge Methods
This transform offers three different methods for merging your lists: Inner
, Left
, and Outer
joins. These three methods mimic the functionality of SQL JOINs and each has its own use cases:
Inner Join: useful when you're dealing with two datasets and only want to focus on data that is common between them.
Left Join: useful when the first list is your primary dataset and you wish to append any additional, relevant data from the second list to it.
Outer Join: useful when you aim for a comprehensive view, combining all data from both lists, and filling in gaps where possible.
Here are some examples of these methods in action to help you better understand their operation:
Results Output
The outputs of the three different merge method examples above can be seen as follows:
Inner Join: only John's object is returned in the output, as his id
is present in both lists.
Left Join: all objects from list_1
are returned, with matching objects from list_2
added on. This is why John's object includes the age from list_2
, but Mary's object remains the same, as there was no matching id
in list_2
.
Outer Join: all objects from both lists are returned, with matching objects merged together. Therefore, we get John's object with the age
from list_2
, Mary's object from list_1
, and the object with id
3 from list_2
which didn't have a matching id
in list_1
.
Now that you're equipped with the knowledge of Merge Lists
transform, you're prepared to blend data from two different lists into a coherent whole. Keep in mind your merging strategy (inner
, left
, or outer
) as it directly impacts your resulting list.
Last updated