Modifying fields

Modifying a field instead of adding a new one is even easier. Supposing that the name of your field is my_field and the value you want to set is stored in a variable named my_var; you just set the field to the new value using the following syntax:

get(Fields.Out, "my_field").setValue(r, my_var); 

By doing it this way, you are modifying the output row. When you send the row to the next step using the putRow() method, the field already has its new value.

In our sample Transformation, we want to convert the word to uppercase. For this, you have to add the following line to your code that converts the word to uppercase:

 get(Fields.Out, "word").setValue(outputRow, word.toUpperCase());

This line takes the uppercase value of the ...

Get Learning Pentaho Data Integration 8 CE - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.