Talend Tips: User Defined Map Function

We have discussed a lot of Talend Integration Studio’s component previously. Today, let’s move on to another interesting tip where we will define our own custom function and use it as a map (User Defined Map Function).

In order to create a user-defined map function, first, you will need to create a custom Routine in Talend as shown in Figure 1 below. In this demo, we named the Routine as DemoFunction.

 

Figure 1: Routine in Talend

 

Please take note that it is important to provide an informative comment on the Routine function as this will help us to understand the usage of the function. Now, we have created the Routine. Let’s take a look on how to call it in a map.

 

In the tMap component, you can call the user-defined function that you have just created by clicking on Expression Builder -> choose *User Defined from the Categories -> double click on the function “udfExample” and it will appear in the Expression Builder.

Figure 2: Expression Builder in tMap

 

Once you have added the user-defined function, you just need to pass in a parameter and it will return you the result. For example, if you pass in a String “Talend Demo”, then it will return you “Talend Demo. This is the “User Defined Function” as the result.

 

Hopefully, this gives you an idea on how to start building your own user defined map function.

Get in touch today to see how WDCi can help your business.