July 30, 2023

tWriteDynamicFields – Docs for ESB 7.x

tWriteDynamicFields

Creates a dynamic schema from input columns in the component.

tWriteDynamicFields creates an output dynamic column from input
columns.

tWriteDynamicFields Standard properties

These properties are used to configure tWriteDynamicFields running in the Standard Job framework.

The Standard
tWriteDynamicFields component belongs to the Processing family.

The component in this framework is available in all subscription-based Talend products.

Basic
settings

Schema and
Edit Schema

A schema is a row description, it defines
the number of fields to be processed and passed on
to the next component. The schema is either
Built-in or
stored remotely in the Repository.

Click Edit
schema
to make changes to the schema. If the current schema is of the Repository type, three options are available:

  • View schema: choose this
    option to view the schema only.

  • Change to built-in property:
    choose this option to change the schema to Built-in for local changes.

  • Update repository connection:
    choose this option to change the schema stored in the repository and decide whether
    to propagate the changes to all the Jobs upon completion. If you just want to
    propagate the changes to the current Job, you can select No upon completion and choose this schema metadata
    again in the Repository Content
    window.

Click Sync
columns
to retrieve the schema from the
previous component in the Job.

 

Built-in:
You create the schema and store it locally for the
relevant component. Related topic: see

Talend Studio User Guide
.

 

Repository:
You have already created the schema and stored it
in the Repository. You can reuse it in various
projects and Job flowcharts. Related topic: see

Talend Studio User Guide
.

Advanced
settings

tStatCatcher
Statistics

Select this check box to gather the Job
processing metadata at a Job level as well as at
each component level.

Global Variables

Global Variables

ERROR_MESSAGE: the error message generated by the
component when an error occurs. This is an After variable and it returns a string. This
variable functions only if the Die on error check box is
cleared, if the component has this check box.

NB_LINE: the number of rows read by an input component or
transferred to an output component. This is an After variable and it returns an
integer.

A Flow variable functions during the execution of a component while an After variable
functions after the execution of the component.

To fill up a field or expression with a variable, press Ctrl +
Space
to access the variable list and choose the variable to use from it.

For further information about variables, see
Talend Studio

User Guide.

Usage

Usage rule

This component handles flow of data
therefore it requires input and output
components.

Creating a dynamic column and extract its content

This scenario applies only to subscription-based Talend products.

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.
    tWriteDynamicFields_1.png

Configuring the components

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

    tWriteDynamicFields_2.png

  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.
    tWriteDynamicFields_3.png

  5. In the schema editor, click on
    otherData column, then click

    tWriteDynamicFields_4.png

    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.

    tWriteDynamicFields_5.png

    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
    .
    tWriteDynamicFields_6.png

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

    tWriteDynamicFields_7.png

    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

    tWriteDynamicFields_8.png

    button in the output area to
    paste the columns copied from tWriteDynamicFields component.

    In the input area, click the Dynamic column and click
    the

    tWriteDynamicFields_4.png

    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.

    tWriteDynamicFields_10.png

  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.

    tWriteDynamicFields_11.png

    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.
    tWriteDynamicFields_12.png

    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.

Extracting the contents of a dynamic column via tJavaRow

This scenario applies only to subscription-based Talend products.

In this scenario, a dynamic column is created via tWriteDynamicFields and its contents are then extracted
by the customized code in tJavaRow.

Linking the components

  1. Drop tFixedFlowInput,
    tWriteDynamicFields, tLogRow and tJavaRow onto the
    workspace.
  2. Link tFixedFlowInput
    to tWriteDynamicFields using the
    Row > Main connection.
  3. Link tWriteDynamicFields to tLogRow using the Row > Main connection.
  4. Link tLogRow to
    tJavaRow using
    the Row > Main connection.

    tWriteDynamicFields_13.png

Configuring the components

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

    tWriteDynamicFields_14.png

  2. Select Use Inline Content
    (delimited file)
    in the Mode area.
  3. In the Content field,
    enter the data to pass to tWriteDynamicFields, for
    example:

  4. Click the Edit schema
    button to open the schema editor.

    tWriteDynamicFields_15.png

  5. Click the [+] button
    to add three columns, namely id, name, and dept, of the Integer and String types
    respectively.
  6. Click OK to validate
    the setup and close the editor.
  7. Double-click tWriteDynamicFields to open its
    Basic settings
    view.

    tWriteDynamicFields_16.png

  8. Click the Edit schema
    button to open the schema editor.

    tWriteDynamicFields_17.png

  9. Click the [+] button
    in the right panel to add two columns, namely
    id and
    dynamic, of the
    Integer and Dynamic types respectively.

    The column id
    contains the value of the column id from tFixedFlowInput and the
    column dynamic
    contains the values of the columns name and dept from tFixedFlowInput.
  10. Click OK to validate
    the setup and close the editor.
  11. Double-click tLogRow
    to open its Basic
    settings
    view.

    tWriteDynamicFields_18.png

    Select Table (print values in
    cells of a table)
    for a better display
    of the results.
  12. Double-click tJavaRow
    to open its Basic
    settings
    view.

    tWriteDynamicFields_19.png

  13. In the Code field,
    enter the Java code to extract the contents of the
    dynamic column dynamic:

    The dynamic column dynamic of the flow row3 is specified for
    retrieving the names, values and types of columns
    that it contains.

Executing the Job

  1. Press Ctrl+S to save
    the Job.
  2. Press F6 to run the
    Job.

    tWriteDynamicFields_20.png

    As shown above, the columns contained in the dynamic
    column have been correctly extracted.

Document get from Talend https://help.talend.com
Thank you for watching.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x