Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I am new to Talend and trying to explore on talend with more use cases. I have a below requirement.
Could any one please suggest on this. I have tried with tmemorize and tmap components and unable to reach the requirement.
Also is it possible to compare previous record with current record in talend as we do in Informatica.
I/P:
ID;DEPTNO;SAL
111;10;200
112;20;300
113;10;400
114;30;500
115;20;500
116;20;200
O/P:
ID;DEPTNO;SAL
111;10;200;200
113;10;400;600
112;20;300;300
115;20;500;800
116;20;200;1000
114;30;500;500
Thanks in Advance..
Regards,
venkat.
Hi,
Here is a solution:
tSortRow to order input by detpno
tJavaRow to compute cumulative values using global variable to store intermediate result:
//Code generated according to input schema and output schema output_row.id = input_row.id; output_row.deptno = input_row.deptno; output_row.sal = input_row.sal; if((Integer)globalMap.get(Integer.toString(row32.deptno)) != null){ output_row.cumul = (Integer)globalMap.get(Integer.toString(row32.deptno)) + input_row.sal; globalMap.put(Integer.toString(input_row.deptno), output_row.cumul); } else{ output_row.cumul = input_row.sal; globalMap.put(Integer.toString(input_row.deptno), input_row.sal); }
The result:
Starting job test at 11:06 10/09/2017. [statistics] connecting to socket on port 3455 [statistics] connected 111|10|200|200 113|10|400|600 112|20|300|300 115|20|500|800 116|20|200|1000 114|30|500|500 [statistics] disconnected Job test ended at 11:06 10/09/2017. [exit code=0]
Hope this helps.
Hi,
Here is a solution:
tSortRow to order input by detpno
tJavaRow to compute cumulative values using global variable to store intermediate result:
//Code generated according to input schema and output schema output_row.id = input_row.id; output_row.deptno = input_row.deptno; output_row.sal = input_row.sal; if((Integer)globalMap.get(Integer.toString(row32.deptno)) != null){ output_row.cumul = (Integer)globalMap.get(Integer.toString(row32.deptno)) + input_row.sal; globalMap.put(Integer.toString(input_row.deptno), output_row.cumul); } else{ output_row.cumul = input_row.sal; globalMap.put(Integer.toString(input_row.deptno), input_row.sal); }
The result:
Starting job test at 11:06 10/09/2017. [statistics] connecting to socket on port 3455 [statistics] connected 111|10|200|200 113|10|400|600 112|20|300|300 115|20|500|800 116|20|200|1000 114|30|500|500 [statistics] disconnected Job test ended at 11:06 10/09/2017. [exit code=0]
Hope this helps.