How to run multiple Transformations from one Job in Pentaho
In this article I am going to talk about how to run multiple transformations from one job using Pentaho. I hope you'll know about pentaho, transformations and jobs. This article include two ways of doing the same process. one method is simple, easy but not much efficient way. However, the second method is more efficient and success way.
First,let's talk about the easy method,
This is the the most common method that you can find from the internet. And also, this is very easy method that fulfill the requirement of running multiple transformations from one job. Let me share an example of this approach and discuss how we are going create this job and the drawbacks of this method.
As you can see in above image, There are 4 transformations connected with the start and when run theabove job all of the execute and run sequentially. If you need to run all of the together in parallel, you can change the settings by Right click one transformation --> select Run Next Entries in Parallel option.
This method can be apply if there are 2 or 3 (less amount) transformations. What will do if there are 100 of transformations? Its really a hassle to create 100 of transformations right? That is the main drawback of this method. We need a convenient way to run 100 of transformations in one job.
Second method will give answers for that questions.
Lets talk about the plan. So our plan is execute multiple transformations by running on job.
In order to achieve this you may need,
- A method to read your ktr names for given location
- A method to pass all names as a parameter
- Finally run all ktr files from one job
The main job(kjb) can be create as follows.
Fig 02: Main Job
To get all ktr names, use Get_Files_Get_all_transformations.ktr. Therefore, above image (Fig 2) inside Transformation, you need to set the path of Get_Files_Get_all_transformations.ktr.
01) Get_Files_Get_all_transformations.ktr can be create as follows.
Fig 03: Get_Files_Get_all_transformations.ktrUpto to this step we developed all necessary developments that required to execute Get_Files_Get_all_transformations.ktr which inside the Main job. (Fig 01). Now let's move in to the 2nd step of the Main job (Fig 01).
02) Launch transformations
This is the inner job and it will execute all ktrs that we pass. In order to do that, we need to create new job and set the path that job inside the Launch transformation in Fig 01. Launch_transformations.kjb can be create as follow in Fig 05. This job uses a parameter called FILENAME based on the results from previous transformation. It uses it to execute a transformation with filename ${FILENAME}.
Fig 05: Launch_Transformations.kjbIn order to create the parameter $(FILENAME) parameter with name and the path, you need another transformation. Set_Variable.ktr will do that process and you need to set the path of Set_Variable.ktr inside Launch_transformations.kjb (Fig 05).
Fig 06: Set_Variable.ktrAs the final step of Launch_transformations.kjb, you need to execute all results that passed on FILENAME parameter. It can done by as below Fig 07.
Fig 07: Execute ${FILENAME}
Hope this will help you all. If you need sample files that I have created, you can get it through GitHub from this link.
Comments
Post a Comment