Search code examples
kettlepdi

Filter Rows Step not working and initializing both the conditions


As in the attached pic. I need to pass to the execute SQL step only if the count value from the table input is <> 0.Else it will move to dummy and wont go to execute process.But it is not working and table is getting deleted which is actually the query written in SQL step and also initialising the dummy as well .(The filter condition is integer so as the table input count value)Image


Solution

  • There are some factors to be taken care in case of your issue:

    1. All the process in PDI are initialized in parallel. So if you are having steps (like Table input, table output, etc) in your transformation. When you execute the ktr, all of these steps are initialized all together.

    2. "Execute SQL Script" step in Pentaho Kettle is self triggering. It gets executed at the initialization phase of the transformation. Check this wiki.

    Solution:

    Check the image below:

    enter image description here

    1. Enable "Execute for each row" in the SQL step:

    The idea is to stop the execution of query during the initialization phase of ktr (Execute SQL Script). So by ticking on the "execute for each row" option will ensure that the SQL step is executed once a row is received and not during the initialization itself.

    Check the below image:

    enter image description here

    2. Use of "ABORT" step (just a suggestion)

    There is no wrong with the use of 'dummy step' but i feel use "Abort" step, which will ensure that current transformation in execution is aborted once the "filter step" returns false condition.

    3. In case you don't like the above two solutions, the only other way out would be create a solution at a job level using "Simple Evaluation" step. This will resolve your issue.

    Attached a sample code in here.

    Hope it helps :)