Dataweave 2.0 Operations in Mule – Part 5

Author: Abhinav Patel

Welcome all, to the DataWeave series for Mule 4.

If you have not gone through the previous articles, I would recommend you go through it first, to get a basic understanding of Dataweave.In this article, we will try to understand the working of joins in dw 2.2

For me, the addition of SQL joining functionality is the biggest addition with Dataweave 2.2 and one of the most awaited one. Join is all about linking to a set of data, keeping in mind there needs to be some condition, popularly known as relationship. An SQL join helps us to create a data record between two-dimensional arrays, consisting of rows and columns.  With Dataweave join operation, we can join an n-dimensional array (of course you need to still get the data right).

Working on a join is always a 2 step process: –

  1. Identification of the data set
  2. Identification of relationship

Let’s take an example to understand the working. 

In our scenario, we will have employee data and parked car details stored in an array. The operation team came up with a requirement to organise the details.

The relationship between the Apisero employee and cars could be established based on id, “emp_id” in apisero_employee and “ownerId” in cars. If we are able to find the ownerId as one of the emp_id is present in apisero_employees table, we can make a statement about the car owner. 

Let’s place this thought in structure. First, let us understand the syntax of join

join(Array<L>, Array<R>, (leftValue: L) -> String, (rightValue: R) -> String): Array<Pair<L, R>>

The output object contains two keys, “l” and “r,” which stand for “left array” and “right array.” In DataWeave, this type of Object is referred to as a Pair. The “l” key contains an item from the left Array, while the “r” key contains an item from the right Array we based to join. The leftValue represents the single item from the left array and the string will be the record that will establish the relationship and the rightValue represents the single item from the right array and the string will be the record that establishes the relationship. 

Let’s start with the classification of the join operation that Dataweave supports

  1. join – documentation 
  2. leftJoin – documentation
  3. outerJoin – documentation

To explain this classification we will go through the visual interpretation of join

Now let’s try to bring our knowledge into action. We will try to use the join operations and then analyse the result so as to have a better understanding of it. 

Now let us try to have a look on another option available to us i.e. leftJoin

I hope you got to learn something new from this walk-through. Also if you have any use case, feel free to share it at

We use cookies on this site to enhance your user experience. For a complete overview of how we use cookies, please see our privacy policy.