It is always a common phenomenon to pass values or variables from parent job to child job in different scenarios in talend. But sometimes, you may need to return values from the child job to parent job too.
This blog discusses a method to return values from child job to parent job in talend.
Returning values from child job to parent job is possible with a tBufferOutput component.
Example Scenario: Parent job sends input value to a child job which finds the square root of the input value and returns it to the parent job.
tFixedFlowInput_1: Fetches the input value for which the square root has to be returned.
tJavaRow_1: Loads the input value into a context value : context.value
tRunJob_1: Child job is called in tRunJob_1. The input value is transmitted into the child job through the context value.
Child Job: Child job calculates the square root value of the input sent from the parent job. This square root value is returned to the parent job using tBufferOutput component.
tFixedFlowInput_1: Fetches the input value from the context.value sent from the parent job.
tJavaRow_1: calculates the square root value and sends it to the buffer output component.
tBufferOutput component sends the output value sqrt_value to the parent.
tBufferOutput component buffers the records in the child job and the tRunjob component in the parent job reads the records from the buffer and passes it to the next component.
**** Note: tRunJob_1 in the parent job should have the same schema as that of tBufferoutput_1 in the child job to get the value returned by the child job.
The square root value is printed in the parent job in tJavaRow_2.
After execution: The parent job returns the output returned by the child job.
Note: **This is a great way to return row data. It is not the most appropriate way for returning control or status data.**
Best Open Source Business Intelligence Software Helical Insight is Here
A Business Intelligence Framework
In case if you have any queries please get us at email@example.com
G R Rajitha
Helical IT Solutions Pvt Ltd