Monday 15 August 2016

Thaumaturge tMap

        Why i call the tMap as a wizardry component is, unlike other components, tMap comes up with versatile functions. With the help of tMap alone we can perform many different operations. There's no wonder that the tMap has become as a data integration job developer's component of choice. Such a main processing component has some of the capabilities such as:
        - Add and remove columns
        - Apply transformation rules to one or more columns
        - Filter input and output data
        - Join multiple inputs into one or many outputs
        - Split input data into multiple outputs

      The tMap also comes with inbuilt java functions where we can use Java ternary operation to perform conditional logic. All will be discussed here.

          In this following example, two tables showing the input 1 in main flow and input 2 in lookup flow where the tMap is used to join the records. 
   




       Join both the files based on "id". We can select any match models in tMap by clicking the tMap settings button. The default match is unique. If unique match is selected, then the main record will be matched with the last matching record in the lookup file and it doesn't care about other matching records. If first match is selected, then  the main record will be matched with the first matching record in the lookup file and doesn't bother the rest of the records.
    But, here we are going to select "All Matches" where main file will be matched with all records in lookup file. 




          The joining method we used here is, left outer join. The left outer join fetches all the records of the left-hand table "input 1", even if there's no matching record in the right-hand table "input 2". So, all input records will become as output and all unmatched records are set to NULL. 
         The result of left outer join can be clearly seen in the following output that contains all the records found in the input. 



          
            
            If we want to take away the "null" record from our output, then we have to give an expression in the expression filter. This expression filter can be enabled by clicking on the + button. Here we are using 

                                row2.order!=null
                                                   (!= means not equal to )




                     
                        That produces the following output without the NULL record, 





                   Now if we want to see that rejected record alone then, we have to use the option called "Catch lookup inner join reject". Before, we have to look on what the Reject Row is. The reject rows are those records that do not match the inner join condition.  
                  tMap has two reject links - Catch Lookup inner join reject and Catch Output Reject. 
                Catch Lookup inner join reject allows us to catch the records rejected by the inner join operation performed on the input flows. 
                Catch Output Reject allows us to catch the records rejected by a filter. 
                Here, we have to set the Catch Lookup Inner Join reject as TRUE. 




               That produces the following desired output,



     

Thank You Very Much for Reading this Article

---------------------------------------------------------------------


No comments:

Post a Comment