Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Talend experts
I have got few questions around output_row.variable not sure what this code is doing. can you please help me understand? (please refer to below screenshot for job ParentCheckExecLoad job where speicifically code is written for SetExecLoad component).
for first SetExecLoad code is written like this:
boolean execload = false;
if (input_row.message.equals("failure") )
execload = true;
else
execload = false;
output_row.execload = execload;
System.out.println("execload: "+execload);
For the second SetExecLoad it's written like this:
boolean execload = false;
if (((Integer)globalMap.get("tRedshiftInput_1_NB_LINE")) == 0)
execload = true;
output_row.execload = execload;
System.out.println("output_row.execload: "+output_row.execload);
Then this parentcheckexecload is being referred in another job like this and execload is also set as shown in below photo.
For this SetExecLoad below code is written:
globalMap.put("ExecLoad",input_row.execload);
I have no idea what does this actually do. Can someone please explain?
Thanks
Harshal
First of all you need to understand that the tJavaRow uses "input_row.{column_name}" to receive column values from your row and the "output_row.{column_name}" to set column values for the output row. So in your job, wherever "output_row" is used, it is basically setting the column value for the row leaving the component.
In the code below, the first SetExecLoad component is testing the value held by the message column. If it is "failure" then it sets an execload boolean to true, otherwise it sets it to false. This is not necessary as it is initialised to false above. It prints out the value of the execload to the output window and passes the execload value to the output_row.
In the second SetExecLoad component it essentially does the same but the setting of execload to true is based on the tRedshiftInput component returning 0 rows.
This bit of code.....
globalMap.put("ExecLoad",input_row.execload);
....sets the globalMap hashmap to have a value supplied by input_row.execload, linked to the key "ExecLoad". It can be retrieved with the following code.....
((Boolean)globalMap.get("ExecLoad"))
....assuming that "input_row.execload" is a boolean.
First of all you need to understand that the tJavaRow uses "input_row.{column_name}" to receive column values from your row and the "output_row.{column_name}" to set column values for the output row. So in your job, wherever "output_row" is used, it is basically setting the column value for the row leaving the component.
In the code below, the first SetExecLoad component is testing the value held by the message column. If it is "failure" then it sets an execload boolean to true, otherwise it sets it to false. This is not necessary as it is initialised to false above. It prints out the value of the execload to the output window and passes the execload value to the output_row.
In the second SetExecLoad component it essentially does the same but the setting of execload to true is based on the tRedshiftInput component returning 0 rows.
This bit of code.....
globalMap.put("ExecLoad",input_row.execload);
....sets the globalMap hashmap to have a value supplied by input_row.execload, linked to the key "ExecLoad". It can be retrieved with the following code.....
((Boolean)globalMap.get("ExecLoad"))
....assuming that "input_row.execload" is a boolean.
All of your data will pass in rows through a Talend flow. Data enters a component in a row by row manner and leaves in the same way. In a tJavaRow you can receive the incoming row data to manipulate it using the input_row prefix, and when you have finished manipulating it you can send it to the next component using the output_row prefix.
It is highly advisable that you learn a bit of Java while learning Talend. It makes understanding how to use the tool a lot easier. It also helps tremendously with debugging.