Home > other >  How to merge tables that don't have the same columns in Talend
How to merge tables that don't have the same columns in Talend

Time:07-20

For a project I'm using Talend, and I have 5 tables that have almost the same columns. But some of the tables have extra columns specific to the table For the moment I've been using tUnite to merge table that have the same columns

I would like to keep them while merging those table and I have no idea how to do it

Example :

Table 1 : col a, col b, col c

Table 2 : col a, col b, col c

Table 3 : col a, col b, col c, col d

I would like that when I'm merging those table col d is merge but appear with no values (blank or null, whatever) for table 1 and table 2

Is there any component that could help me do that ? Am I missing something obvious ?

CodePudding user response:

Your job should be designed as below :

tdbinput1(table 1) -> main                       -> 
                                                 |
tdbinput2(table 2) ->    main                    ->   tunite -> tlogrow
                                                 |
tdbinput3(table 3) -> main ->tFilterColumns->main 

In the tFilterColumns component you can ignore your col d

See below documentation of tFilterColumns

https://help.talend.com/r/fr-FR/7.2/processing/tfiltercolumns-standard-properties

Or if col d is needed just add the columns using tMap component

tdbinput1(table 1) -> main ->tmap1 (add col d)    -> 
                                                 |
tdbinput2(table 2) ->    main ->tmap2 (add col d)                ->   tunite -> tlogrow
                                                 |
tdbinput3(table 3) ->  main 

CodePudding user response:

tUnite will require that all schemas are the same. Most convenient solution would be to add columns to table 1 and 2 (through a tMap for example) with null value, so schema of tables 1/2 would be the same as table3.

  • Related