Scenario: Let's say we have one source with 20 records and 3 targets X,Y,Z.I have to load first record into X, 2nd record into Y, 3rd record into Z and again 4th record into X, 5th record into Y, 6th record into Z and so on up to last record.
Solution: We can implement this using Sequence Generator,Expression,Router transformations. Pull all the required fields from Source Qualifier to Expression transformation (apply business logic if required), create one extra port (Let's say REC_NUM) and then link the "Next Value" field from the Sequence Generator to REC_NUM in Expression. From Expression, Pull the required fields into Router transformation including REC_NUM and then create 3 groups in Router as we have 3 targets(m groups for m targets). Use the below conditions and then connect each group to respective target.
Group 1 -- MOD(REC_NUM,3)=1 -- Connect to X
Group 2 -- MOD(REC_NUM,3)=2 -- Connect to Y
Group 3 -- MOD(REC_NUM,3)=0 -- Connect to Z
Solution: We can implement this using Sequence Generator,Expression,Router transformations. Pull all the required fields from Source Qualifier to Expression transformation (apply business logic if required), create one extra port (Let's say REC_NUM) and then link the "Next Value" field from the Sequence Generator to REC_NUM in Expression. From Expression, Pull the required fields into Router transformation including REC_NUM and then create 3 groups in Router as we have 3 targets(m groups for m targets). Use the below conditions and then connect each group to respective target.
Group 1 -- MOD(REC_NUM,3)=1 -- Connect to X
Group 2 -- MOD(REC_NUM,3)=2 -- Connect to Y
Group 3 -- MOD(REC_NUM,3)=0 -- Connect to Z
Similar Scenario: Here just I want to load first 5 records into X, next 5 records into Y ,next 5 records into Z and again next 5 records into X and so on till the last record (this is like n records into m targets). Here the condition will be
Group 1 -- MOD(ROW_NUM,15)>=1 and MOD(ROW_NUM,15)<=5
Group 2 -- MOD(ROW_NUM,15)>=6 and MOD(ROW_NUM,15)<=10
Group 3 --
(MOD(ROW_NUM,15)>=11 and MOD(ROW_NUM,15)<=14) or (MOD(ROW_NUM,15)=0)
Here the value is 3x5 i.e mxn
Hope this article helps you to understand two scenarios with same logic.
Comments
Post a Comment