Scenario 1: Create a dynamic column and extract its content - 6.1

Talend Components Reference Guide

EnrichVersion
6.1
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
EnrichPlatform
Talend Studio
task
Data Governance
Data Quality and Preparation
Design and Development

This Java scenario contains five components. It aims at creating a Dynamic type column from a schema and extracting the columns contained in this dynamic column. These transformation results are displayed into the console.

Linking the components

  1. From the Palette to the design workspace, drag and drop the following components:

    - a tRowGenerator to generate a flow containing customer information,

    - a tWriteDynamicFields to replace columns with a Dynamic column,

    - two tLogRow to display the results into the console,

    - a tExtractDynamicFields to extract content from the dynamic column.

  2. Connect tRowGenerator to tWriteDynamicFields using a Row > Main link.

  3. Connect tWriteDynamicFields to the first tLogRow using a Row > Main link.

  4. Connect tLogRow to tExtractDynamicFields using a Row > Main link.

  5. Connect tExtractDynamicFields to the second tLogRow using a Row > Main link.

  6. Rename both tLogRow by double-clicking them.

    Type in their new name, dynamicColumn and standard column respectively.

Configuring the components

  1. In the design workspace, double-click the tRowGenerator to open its editor.

  2. Click seven times on the [+] button to add seven columns to the schema. Name them id, firstName, lastName, street, city, States and otherData, respectively.

  3. In the Type column, select Integer for id and String for all other fields.

    In the Functions columns, select the function you want to apply to each column in the schema.

    Click OK to validate the configuration and close the editor.

    A pop-up window opens and asks you to propagate the changes. Click Yes.

  4. In the design workspace, double-click tWriteDynamicFields component to display its Basic settings view.

    Click the [...] button next to Edit schema to set the schema of the component.

  5. In the schema editor, click on otherData column, then click to add the column on the output side.

    This way, the column will be displayed in the output, but it will not be included into the dynamic column.

  6. Click the [+] button in the output area to add a column.

    Name it columnDynamic and set its Type to Dynamic.

    Warning

    The dynamic column must be defined in the last row of the schema.

    Warning

    The column names must be exactly the same on both sides of the editor, otherwise the output columns will not be recognised.

  7. Click OK to validate your changes and close the editor.

    Warning

    The dynamic schema feature is only supported in Built-In mode.

    All columns that are not in the output area in the editor will be included into the dynamic column.

  8. In the design workspace, double-click the first tLogRow to display its Basic settings view.

    In the Mode area, select the Table (print value in cells of a table) option.

  9. In the design workspace, double-click tWriteDynamicFields component to display ots Basic settings view.

    Click the [...] button next to Edit schema.

  10. Select in the left area the columns you want to add to the tExtractDynamicFields schema and click the button to copy them.

    Click OK to close the editor.

  11. In the design workspace, double-click the tExtractDynamicFields component to display its Basic settings view.

    Click the [...] button next to Edit schema.

    In the schema editor, click the button in the output area to paste the columns copied from tWriteDynamicFields component.

    In the input area, click the Dynamic column and click the button to add the dynamic column to the output schema.

    Click OK to validate your changes and close the editor.

  12. In the design workspace, double-click the second tLogRow to display its Basic settings view.

  13. In the Mode area, select Table (print value in cells of a table) option.

Executing the Job

  1. Press Ctrl+S to save the Job.

  2. Press F6 to execute it.

    The first tLogRow component displays in the console the dynamic column in addition to the otherData column you have already defined in the output schema of the tWriteDynamicFields component.

    The second tLogRow displays in the console all the extracted columns (id, firstName and lastName) from the dynamic one, the otherData column that has not been included into the dynamic column and the dynamic column which still contains all columns voluntarily not extracted.