Talend Tips: Connector lookup in tMap

Are you aware that you can actually do a connector lookup in Talend by using tMap component to retrieve the data? This is very useful as it helps to retrieve the data that you want instead of loading additional unnecessary data into Talend and helps to improve the performance of the Talend job.


I’m going to show you a simple example of how to achieve this


Figure 1: Overview of the process


The screenshot above shows the overview of the process that we are going to build. In this demo, I will focus on configuring the tMap component to enable lookup function and get the “getContactByAccountId” tSalesforceInput component to query Salesforce contact by AccountId.


Step 1: To enable the lookup function, you need to change the lookup model in the tMap to “Reload at each row” as shown in Figure 2.
Figure 2: tMap configuration
Step 2: As soon as you change the lookup model, a new configuration section which contains the “Expr.” and “globalMap key” will appear. This is the place where you specify the lookup key and the value to be hold by the lookup key. In this example, I use “accountid” as the key and map the Id field from “account” main flow to it as the lookup value. You can also see that the same Id field is mapped to the “AccountId” in “contact” lookup flow. This is to tell Talend that I would like to join the result of the main flow with lookup flow and match them with “AccountId”. You can refer to an old post if you would like to know more about¬†Join Model in tMap.
Step 3: Now, click on Ok to save the changes and we will move on to configure the “getContactByAccountId” tSalesforceInput component. In the Query Condition input box of the tSalesforceInput component, you just need to specify the lookup key that you configured in the tMap. In order to get the value of the lookup key, you need to call it as following (or as shown in Figure 3):
Figure 3: Get the value of lookup key
Yup, now we are done. The Talend job now has connector lookup function enabled!