If Statement in Reformat Component

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.

Eg.
Input Table1
num1
num2

Output Table2
num

if (num1 == 1 || num2 == 1)
{
num =1;
}
else
num = 0 ;

Hi,

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:

function integer transform() {
if ($in.0.num1 == 1 || $in.0.num2 == 1)
{
$out.0.num =1;
}
else
$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.

Eva