Java - Informatica Scenario Based Interview Questions (Convert Columns Into Rows)
Java - Informatica Scenario Based Interview Questions (Convert Columns Into Rows)
This is the one of most frequently asked informatica scenario based interview question.
A B C
Output required is
A
B
C
I have seen rarely a candidate answer this question correctly. Their answer is mostly a
crammed (by reading on various website) without understanding core concept of
informatica transformations.
I will explain three methods to achieve this then we will find out which one is best
method
1. Router Transformation
2. Normalizer Transformation
3. Java Transformation
Router Transformation : This method take advantage of the fact that router is an
active transformation and one row can fall into multiple groups i.e. if a row satisfies
condition of three groups then it will fall into three groups and will produce three rows
for one input row.
Step1)
Suppose we have a source with three input columns
Step2) Create an expression Transformation with field name FLD_OUTPUT to
concatenate three fields separated by # sign
Step3) Create a router transformation with three output groups with condition
GROUP1 : substr(FLD_OUTPUT,1,instr(FLD_OUTPUT,'#')-1)=FLD1
GROUP2 :
substr(FLD_OUTPUT,instr(FLD_OUTPUT,'#')+1,instr(FLD_OUTPUT,'#',2)-1)=FLD2
GROUP3: substr(FLD_OUTPUT,instr(FLD_OUTPUT,'#',3)+1)=FLD3
Purpose of this is that row will fall into three groups ..we are extracting string from
concatenated string are comparing to respective field.i.e value A will be in first group
and B in second group and so on…
Step4) Create union transformation to combine output from three output group from
router..Take FLD1 from first group, FLD2 from second group ,FLD3 from third group
Output from union will be
A
B
C
Core Concept: if a row satisfies condition of three groups then it will fall into three
groups and will produce three rows for one input row.
Easy isn’t it …No need to cram. We will now move to other methods…
You can define number of occurrence of source field, Once you define number of
occurrence then informatica automatically creates that number of input ports. In this
case 3
Connect FLD1, FLD2 and FLD3 from source or expression in step2 of first method and
FLD as output connected to target.
A
B
C
Generate Transaction The transformation generates transaction rows. You can enable this
property for active Java transformations.
Create a java transformation with one input and one output field
Now connect concatenated field (A#B#C) from expression in step2 of first method to
FLD_INPUT of java transformation
String[] str_fld_nm=FLD_INPUT.split("#");
for(int i=0; i
FLD_OUTPUT =str_fld_nm[i];
generateRow();
}
It is using java functionality of array to break input field and multiple fld and then
taking advantage of generateRow() to produce multiple rows.
A
B
C
Core concept : Java functionality to break concatenated string into multiple fields and
generateRow() to produce multiple rows.
Now we have covered all three features. Let us see which one is best