Pentaho Kettle's support for Java and JavaScript greatly increases its flexibility to deal with various transformation needs. Here we take a look at the Java Filter step that you can write a Java expression to filter data records.
The overview transformation diagram is illustrated as below.
We want to pick out salesman's records. To make the condition a little bit more complicated, we want SAL to be not less than 1500 as well.
The matching data flows to "toFile" step, and the non-matching data goes to "toDummy" step.
Be noticed that non-matching destination step must be specified; otherwise you will get "failed to initialize" error when you try to execute the transformation.
Save the transformation and execute it. You will see the filter results shown by the below tables.
"toFile" destination step:
"toDummy" destination step:
Additionally, conditional operator (? :) can be used for sure.
E.g. (DEPTNO == 10) ? Boolean.TRUE : Boolean.FALSE
For dates comparison, use compareTo() method, for example, Date1.compareTo(Date2).
No comments:
Post a Comment