Function tMap is an advanced component, which integrates itself as a plugin to Talend Studio.
Purpose tMap transforms and routes data from single or multiple sources to single or multiple destinations.
The TMAP COMPONENT has extensive transformation capabilities and has thus become the data integration developer’s tool of choice. The tMap component’s capabilities are the ability to:
The tMap component provides much more functionality beyond this, including Joins and Filtering.
If you would like to Enrich your career with a Talend certified professional, then visit Mindmajix - A Global online training platform: “Talend Course”. This course will help you to achieve excellence in this domain.
The tMap component is multipurpose and very flexible and because of this, there is often the temptation to do as much as possible in a single tMap component. This isn’t recommended since this can raise the complexity to a level where the code becomes difficult to understand and to maintain. It is recommended that multiple tMap components be used to manage complex transformations so that the code is more easily understood.
One of the main limitations of tMap is that the output expressions for transformation are limited to just a single line. This can be overcome using code routines that perform complex logic or utilizing tMap variables and the Java ternary operation can be used to perform conditional logic.
The operation of lookups (for joining) can be manipulated in tMap to enable efficient joining in both batch and real-time mode.
This recipe will illustrate the most basic mapping options within the tMap component and some of the column level tricks that can be used to speed up the mapping by removing large amounts of repetitive actions.
-------- Related Page: Joining Data Using tMap, Hierarchical Joins --------
Getting started tMap time savers
Open the job jo_cook_ch04_0010_basicMapping.
You can move a row or column by dragging-and-dropping it to a new location.
If you want to remove a column you do not need, you can delete a column.
tMap enables columns to be mapped, ignored, and added to the output very easily to ensure that the correct results are produced.
Shortcuts such as Automap! and the group copies, enable many rows to be copied at once, saving time and effort.
New columns can be created by dragging and dropping from the input, as well as via the schema editor.
Always name the inputs to tMap. Often, tMaps have multiple inputs and outputs. Ensuring that the flow names are consistent help in identifying from where a data element has been sourced, which will make debugging easier.
This recipe will show how to add much more complex rules to tMap and how to use the Talend supplied functions.
Expressions are limited to a single line of Java code, but can contain any of the following:
Open the job jo_cook_ch04_0020_usingExpressions
The expression editor allows drag-and-drop creation of complex transformation rules. It also includes panels for accessing Talend supplied and user-created functions to make building rules much easier.
The expression builder also has test functionality, making it a powerful Talend feature, but it isn’t the only way to create expressions.
The expression builder will also allow the Value column and clicking the Test! an expression to be tested by filling in values in button, as shown:
Although the expression builder is useful, it can also be time-consuming to open and close the editor continuously. More seasoned Talend developers will often not use the expression builder, preferring instead to edit the line directly in the main tMap window expression column or in the expanded expression window, which is an alternative tab of the schema panel, shown in the following screenshot:
Although tMap expressions are limited to a single line of code, the use of the tMap variables, ternary expressions, and code routines do allow very complex mappings to be handled within a single expression.
Ravindra Savaram is a Content Lead at Mindmajix.com. His passion lies in writing articles on the most popular IT platforms including Machine learning, DevOps, Data Science, Artificial Intelligence, RPA, Deep Learning, and so on. You can stay up to date on all these technologies by following him on LinkedIn and Twitter.