- Pentaho Data Integration Beginner's Guide(Second Edition)
- María Carina Roldán
- 722字
- 2021-07-23 15:47:01
Time for action – assigning tasks by filtering priorities with the Filter rows step
Continuing with the JIRA subject, let's do a more realistic distribution of tasks among programmers. Let's assign the severe task to our most experienced programmer, and the other tasks to others.
Create a new transformation.
Read the JIRA file and filter the unassigned tasks, just as you did in the previous section.
- Add a Filter rows step. Create a hop from the previous Filter rows step toward this new filter. When asked for the kind of hop, select Main output of step.
- Add two Microsoft Excel Output steps.
- Create a hop from the last Filter row to one of the Microsoft Excel Output steps. As the type for the hop, select Result is TRUE.
- Create a hop from the last Filter row to the other Excel step. This time as the type for the hop, select Result is FALSE. The transformation looks as follows:
- Double-click on the Filter rows step to edit it.
Note
Note that the content of the textboxes Send "true" data to step and Send "false"data to step should be the names of the destination steps - the two Microsoft Excel Output steps.
- Enter the condition
Priority = [Critical] OR Priority = [Severe] OR Priority = [Blocker]
.Tip
Alternatively you can use a single condition:
Priority IN LIST Critical;Severe;Blocker
. - Configure the Microsoft Excel Output step located at the end of the green hop. As fields, select Priority and Summary, and as the name for the file type
b_bouchard.xls
(the name of the senior programmer). - Configure the other Microsoft Excel Output step to send the fields Priority and Summary to an Excel file named
new_features_to_develop.xls
. - Click on OK and save the transformation.
- Run the transformation, and verify that the two Excel files were created. The files should look like this:
What just happened?
You sent the list of PDI new features to two Excel files: one file with the blocker, severe, and critical issues, and the other file with the rest of the issues.
In the Filter rows step, you put a condition to evaluate if the priority of a task was blocker, severe, or critical. For every row coming to the filter, the condition was evaluated.
The rows that met the condition, that is, those that had one of those three priorities, followed the green hop. This hop linked the Filter rows step with the Microsoft Excel Output step that creates the b_bouchard.xls
file. If you take a look at the Filter rows configuration window, you can also see the name of that step in the Send 'true' data to step textbox.
The rows that did not meet the condition, that is, those with another priority, were sent toward the other Microsoft Excel Output step, following the red hop. This hop linked the Filter rows step with the Microsoft Excel Output step that creates the new_features_to_develop.xls
file. In this case, you can also see the name of the Microsoft Excel Output step in the Send 'false' data to step textbox.
PDI steps for splitting the stream based on conditions
When you have to make a decision, and upon that decision split the stream into two, you can use the Filter rows step as you did in this last exercise. In this case, the Filter rows step acts as a decision maker: it has a condition and two possible destinations. For every row coming to the filter, the step evaluates the condition. Then, if the result of the condition is true, it decides to send the row towards the step selected in the first drop-down list of the configuration window: Send 'true' data to step.
If the result of the condition is false, it sends the row towards the step selected in the second drop-down list of the configuration window: Send 'false' data to step.
Alternatively, you can use the Java Filter step. As said in the last chapter, the purpose of both steps—Filter rows and Java Filter—is the same; the main difference is the way in which you type or enter the conditions.
Sometimes you have to make nested decisions, for example:

When the conditions are as simple as testing whether a field is equal to a value, you have a simpler way for creating a transformation like the one shown previously.