If Statement in Reformat Component

Support/help with CloverETL implementation problems

Posts: 3
Joined: Thu Apr 20, 2017 8:47 am

If Statement in Reformat Component

Postby cloveretluseruser » Thu Apr 20, 2017 8:54 am

Hi all,
I am using CloverETL Designer Community Edition.
How do I use the if statement in the Reformat component?

I have an input table (Table1) and output table (Table2)
I would like to insert 1 into num in output table if num1 or num2 in input table is 1. Else, num will be 0.

Input Table1

Output Table2

if (num1 == 1 || num2 == 1)
num =1;
num = 0 ;

Posts: 38
Joined: Fri Nov 04, 2016 8:51 am

Re: If Statement in Reformat Component

Postby jandikovae » Fri Apr 21, 2017 10:52 am


In the CloverETL tool, the only thing you should keep in mind is the way how you refer to the variables in all transformations. I mean, you should define what input/output port and field name you are referring to. Your code in Reformat component would then look as follows:

Code: Select all

function integer transform() {
if ($in.0.num1 == 1 || $in.0.num2 == 1)
$out.0.num =1;
$out.0.num = 0 ;
    return ALL;

The "$in.0num1" variable means that the value is taken from the field called "num1" (defined in appropriate metadata) and it is coming from input port 0.

For more information please see the documentation http://doc.cloveretl.com/documentation/ ... ditor.html.

Or you can also review the attached example. Please note that in the example graph I have decided to define output metadata to be of boolean data type, therefore the resulting transformation slightly differs.

Hope this helps. Best Regards.

Input data
(31 Bytes) Downloaded 59 times
Example Graph
(2.69 KiB) Downloaded 53 times
Eva Jandikova
CloverCARE Support
CloverETL | Rapid Data Integration

Visit us online at http://www.cloveretl.com
How to speed up communication with CloverCARE support