Question

suppose I have the following source table (called S):

name   gender code

Bob         0          
Nancy       1          
Ruth        1          
David       0          

And let assume I also have a lookup table (called S_gender_values):

Gender_Code Gender_value

0           Male           
1           Female 

My goal is to create a target table (lets call it T) which will look like this:

name   Gender_Code    

Bob     M             
Nancy   F             
Ruth    F             
David   M             

I also assume that I have a lookup table for table T, called T_GenderValues, which I can use in order to create table T (and validate its results)

Gender_Code    Gender_value   

M                Male          
F                Female        

I thought about 2 (or 3) alternatives:

  1. create a mapping table (lets call it S_T_Gender_Code_Mapping) which will look like this:

    S_Gender_Code     T_Gender_code     
    
    0                   M               
    1                   F    
    

    and then do a simple join/lookup using tMap.

  2. use tMap and add expression which will implement the mapping, something like:

    (S.Gender_Code==0)?"F":"M"
    
  3. similar to Alternative 2 but to use user Java routines.

Is there an other alternative? I hoped I could leverage the ease of tMap to map between S_GenderValues and T_GenderValues and to benefit from the usability of UI tool like we have in tMap

Any hint?

Was it helpful?

Solution

To me, it seems option #1 is needlessly complex and could slow the process. Sure, if you had dozens or thousands of lookups, that's what you'd want, but not for two.

And option #3 is also too much, as you're going to want to merge the value into a flow or iterate stream anyway (components like tJavaRow are there to make more complex transformations).

The tMap component can do the simple one-line Java right in the flow, so option 2 sounds to me like your best choice.

OTHER TIPS

I've solved a similar situation to yours, my main problem was that i had one big lookup table with every type of lookup in the same place.

If your problem grows to more options instead of only two, the third approach is good to have in mind, so you might want to take a look at this solution, it maps the contents of the lookup table to global variables a lists, and then lookups them.

Talend internal variables

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top