Monday, May 11, 2020

Pentaho - Java Filter

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.


The data comes from EMP table which resides in an Orace XE database, as shown in the following image.



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

React - Makeover in React: W3Schools How To

When it comes to building a React app, I get used to searching for a UI library to build the front pages, a straightforward way to achieve f...