Scenario 3: Combining two flows for selective output - 6.3

Talend Components Reference Guide

EnrichVersion
6.3
EnrichProdName
Talend Big Data
Talend Big Data Platform
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for Big Data
Talend Open Studio for Data Integration
Talend Open Studio for Data Quality
Talend Open Studio for ESB
Talend Open Studio for MDM
Talend Real-Time Big Data Platform
task
Data Governance
Data Quality and Preparation
Design and Development
EnrichPlatform
Talend Studio

In this scenario, a flow generated by tFixedFlowInput is combined with a flow from the Mysql database. The source flow contains id and age fields while the Mysql table contains id and name. We want to retrieve the age data of the source flow and combine it with the id and name records from the Mysql table based on id matching. One thing that is worth noting is that the input schema is different from the output one at tMysqlRow in the Job.

Linking the components

  1. Drop tFixedFlowInput, tMysqlRow, tParseRecordSet and tLogRow onto the workspace.

  2. Rename tFixedFlowInput as source_flow, tMysqlRow as insert_recordset, tParseRecordSet as parse_recordset and tLogRow as show_combined_flow.

  3. Link tFixedFlowInput to tMysqlRow using a Row > Main connection.

  4. Link tMysqlRow to tParseRecordSet using a Row > Main connection.

  5. Link tParseRecordSet to tLogRow using a Row > Main connection.

Configuring the components

  1. Double-click tFixedFlowInput to open its Basic settings view.

  2. Select Use Inline Content (delimited file) in the Mode area.

    In the Content field, enter the data to be transferred:

    1;30
    2;20
  3. Double-click the [...] button next to Edit schema to open the schema editor.

    Click the [+] button to add two columns, namely id and age, with the type of Integer.

    Click Ok to close the editor.

  4. Double-click tMysqlRow to open its Basic settings view.

  5. In the Host and Port fields, enter the connection details.

    In the Database field, enter the database name.

    In the Username and Password fields, enter the authentication details.

    In the Query field, enter the SQL query to retrieve the id and name data from the Mysql table employee: "select id, name from employee WHERE id=?".

    The question mark, "?", represents the parameter to be set in the Advanced settings tab.

  6. Click the [...] button next to Edit schema to open the schema editor.

  7. Click the [+] button to add two columns in the right part, namely recordset and age, with the type of Object and Integer. Note that recordset is intended to hold the query results of the Mysql table, namely the id and name fields.

    Click OK to close the editor.

  8. Click the Advanced settings tab for further setup.

  9. Select the Propagate QUERY's recordset check box and choose recordset from the use column list to insert the query results in that column.

    Select the Use PreparedStatement check box and define the parameter used in the query in the Set PreparedStatement Parameters table.

  10. Click on the [+] button to add a line.

    In the Parameter Index cell, enter the parameter position in the SQL instruction. Enter "1" as we are only using one parameter in this example.

    In the Parameter Type cell, enter the type of parameter. Here, the parameter is an integer. Hence, select Int from the list.

    In the Parameter Value cell, enter the parameter value. Here, we want to retrieve the id and name from the employee table based on the id value from the source flow. Hence, enter row3.id.

  11. Double-click tParseRecordSet to open its Basic settings view.

    From the Prev. Comp. Column list, select the column to parse, namely recordset.

  12. Click the [...] button next to Edit schema to open the schema editor.

    Click the [+] button to add three columns in the right part, namely id, name and age, with the type of Integer, String and Integer. Note that the id and name fields are intended to hold the parsed data of recordset.

    Click OK to close the editor.

    In the Attribute table, in the Value fields which correspond to id and name, enter the name of the column in the Mysql table to be retrieved, namely "id" and "name".

  13. Double-click tLogRow to open its Basic settings view.

    In the Mode area, select Table (print values in cells of a table for better display.

Executing the Job

  1. Press Ctrl+S to save the Job.

  2. Press F6 to run the Job.