Today, I will discuss about the how to apply loop in Pentaho. Here, first we need to understand why Loop is needed. For example, you need to run search a file and if file doesn’t exists , check the existence of same file again in every 2 minutes until you get the file or another way is to search x times and exit the Loop.
See the below ETL job where i created a simple Loop.
Set Variables : create a new variable NEW_LOOP and set its value to 0.
File Exists : Look for a particular file, if that file is present, exit from the job successfully else go to “trans-loop” Transformation.
Trans-Loop Transformation: Here, we need to increment that Loop(NEW_LOOP) by 1 and set the same variable which is NEW_LOOP.
Simple Evaluation: Here, we are evaluating NEW_LOOP variable with 2. You can change this value based on your project needs. Here, this loop will run two times.If NEW_LOOP variable reaches value 2, then it will abort the job.
Wait For: Now, I have already explained in the beginning that we need to put a wait before it will check for same file again. Here , I have put a wait of 10 seconds.
Modify this job based on your project needs.