July 30, 2023

tJoin – Docs for ESB 7.x

tJoin

Performs inner or outer joins between the main data flow and the lookup
flow.

tJoin joins two tables by doing an
exact match on several columns. It compares columns from the main flow with reference
columns from the lookup flow and outputs the main flow data and/or the rejected
data.

tJoin Standard properties

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

The Standard
tJoin component belongs to the Processing family.

The component in this framework is available in all 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.

This
component offers the advantage of the dynamic schema feature. This allows you to
retrieve unknown columns from source files or to copy batches of columns from a source
without mapping each column individually. For further information about dynamic schemas,
see
Talend Studio

User Guide.

This
dynamic schema feature is designed for the purpose of retrieving unknown columns of a
table and is recommended to be used for this purpose only; it is not recommended for the
use of creating tables.

 

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

Talend Studio User
Guide
.

 

Repository: The schema already
exists and is stored in the Repository, hence can be reused in
various projects and Job flowcharts. Related topic: see

Talend Studio User
Guide
.

Include lookup columns in output

Select this check box to include the lookup columns you define in
the output flow.

Input key attribute

Select the column(s) from the main flow that needs to be checked
against the reference (lookup) key column.

Lookup key attribute

Select the lookup key columns that you will use as a reference
against which to compare the columns from the input flow.

Inner join (with reject output)

Select this check box to join the two tables first and gather the
rejected data from the main flow.

Advanced settings

tStat
Catcher
Statistics

Select this check box to collect log data at the 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.

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 is not startable and it requires two input
components and one or more output components.

Doing an exact match on two columns and outputting the main and rejected
data

This scenario describes a five-component Job aiming at carrying out an exact match
between the firstnameClient column of an input file against the
data of the reference input file, and the lastnameClient column
against the data of the reference input file. The outputs of this exact match are
written in two separate files: exact data are written in an Excel file, and inaccurate
data are written in a delimited file.

In this scenario, we have already stored the input schemas of
the input and reference files in the Repository. For more information about storing
schema metadata in the Repository tree view, see

Talend Studio User Guide
.

Dropping and linking the components

  1. In the Repository tree view, expand
    Metadata and the file node where you
    have stored the input schemas and drop the relevant file onto the design
    workspace.

    The Components dialog box
    appears.
    tJoin_1.png

  2. Select tFileInputDelimited from the list
    and click OK to close the dialog
    box.

    The tFileInputDelimited component
    displays in the workspace. The input file used in this scenario is called
    ClientSample. It holds four columns including the
    two columns firstnameClient and
    lastnameClient we want to do the exact match
    on.
  3. Do the same for the second input file you want to use as a reference,
    ClientSample_Update in this scenario.
  4. Drop the following components from the Palette onto the design workspace: tJoin, tFileOutputExcel,
    and tFileOutputDelimited.

    tJoin_2.png

  5. Connect the main and reference input files to tJoin using Main links. The
    link between the reference input file and tJoin appears as a lookup link on the design
    workspace.
  6. Connect tJoin to tFileOutputExcel using the Main link and tJoin to
    tFileOutputDelimited using the
    Inner join reject link.

Configuring the components

  1. If needed, double-click the main and reference input files to display
    their Basic settings views. All their
    property fields are automatically filled in. If you do not define your input
    files in the Repository, fill in the
    details manually after selecting Built-in
    in the Property Type field.
  2. Double click tJoin to display its
    Basic settings view and define its
    properties.

    tJoin_3.png

  3. Click the Edit schema button to open a
    dialog box that displays the data structure of the input files, define the
    data you want to pass to the output components, three columns in this
    scenario, idClient,
    firstnameClient and
    lastnameClient, and then click OK to validate the schema and close the dialog
    box.

    tJoin_4.png

  4. In the Key definition area of the
    Basic settings view of tJoin, click the plus button to add two columns
    to the list and then select the input columns and the output columns you
    want to do the exact matching on from the Input key
    attribute
    and Lookup key
    attribute
    lists respectively,
    firstnameClient and lastnameClient in this example.
  5. Select the Inner join (with reject
    output)
    check box to define one of the outputs as inner join
    reject table.
  6. Double click tFileOutputExcel to display
    its Basic settings view and define its
    properties.

    tJoin_5.png

  7. Set the destination file name and the sheet name, and select the Include header check box.
  8. Double click tFileOutputDelimited to
    display its Basic settings view and define
    its properties.

    tJoin_6.png

  9. Set the destination file name, and select the Include header check box.

Saving and executing the Job

  1. Press Ctrl+S to save your Job.
  2. Press F6, or click Run on the Run tab to
    execute the Job.

    tJoin_7.png

    The output of the exact match on the firstnameClient
    and lastnameClient columns is written to the defined
    Excel file.
    tJoin_8.png

    The rejected data is written to the defined delimited file.
    tJoin_9.png

Matching input data against a reference file based on a dynamic
column

This scenario applies only to subscription-based Talend products.

This scenario describes a five-component Job that matches the family information
entries in the main input file against those in a reference input file, and displays the
exact matches and the rejected data in different tables on the console. The dynamic
feature is leveraged to save the time of configuring individual columns in the schema of
each component.

tJoin_10.png

Dropping and linking the components

  1. Drop two tFileInputDelimited components,
    a tJoin component, and two tLogRow components from the Palette onto the design workspace, and label them to better
    identify their roles in the Job, as shown above.
  2. Connect the tFileInputDelimited component
    labelled Main_Input to the tJoin component, which is labelled Check, using a Row > Main
    connection.
  3. Repeat the step above to connect the tFileInputDelimited component labelled Ref_Input to the tJoin component. This Row
    connection automatically appears as a lookup link.
  4. Connect the tJoin component to the
    tLogRow component labelled Matches using a Row > Main connection. This
    link will gather the data of the exact matches.
  5. Connect the tJoin component to the
    tLogRow component labelled Rejects using a Row > Inner join reject
    connection. This link will gather the rejected data.

Configuring the components

  1. Double-click the tFileInputDelimited
    component labelled Main_Input to display
    its Basic settings view.

    tJoin_11.png

    Warning:

    The dynamic schema feature is only supported in Built-In mode and requires the input file to have a
    header row.

  2. Click the […] button next to the
    File Name/Stream field to browse to
    your main input file, and type in 1 in
    the Header field to define the first row as
    the header row.

    In this use case, the main input file contains the following
    information:
  3. Click Edit schema to define the schema
    for this component.

    In this use case, the main input file has five columns: FirstName, LastName, HouseNo,
    Street, and City. However, as we can leverage the advantage of the
    dynamic schema feature, we simply define two columns: one string type of
    column for the first names of people, and one dynamic column for the family
    information. To do so:
    1. Click the [+] button to add two
      columns, and name them FirstName
      and FamilyInfo
      respectively.
    2. Select String from the Type list for the FirstName column to retrieve the first name of each
      person on the name list.
    3. Select Dynamic from the Type list for the FamilyInfo column to retrieve the rest information
      of each person on the name list: the last name, house number,
      street, and city, which all together will identify a family.

      tJoin_12.png

    4. Click OK to propagate the schema
      and close the Schema dialog
      box.
  4. Following steps similar to the above, define the properties for the
    tFileInputDelimited component labelled
    Ref_Input: the path to the reference
    input file, the header row, and the schema. This time, just define one
    dynamic column, FamilyInfo, to retrieve
    the four columns of the reference input file, which contains the following
    information:

  5. Double-click the tJoin component to open
    its Basic settings view.

    tJoin_13.png

  6. Click Edit schema to open the Schema dialog box to check the data structures
    of the input files and define the data you want to pass to the output
    components.

    In this scenario, we want to pass both columns of the main input file,
    FirstName and FamilyInfo, to the output files, so simply copy the schema
    columns of the main input file by clicking the ->> button. Then, click OK to validate the schema and close the dialog box.
    tJoin_14.png

  7. In the Key definition area, click the
    [+] button to add one column to the
    list and then select the input column you want to match from the Input key attribute list and the reference column
    against which you want match the input column from Lookup key attribute list, FamilyInfo and row2.FamilyInfo respectively in this example.
  8. Make sure that the Inner join (with reject
    output)
    check box is selected to define one of the outputs as
    inner join reject table.
  9. In the Basic settings view of each
    tLogRow component, select the Table option to display the output information in
    table cells.

Saving and executing the Job

  1. Press Ctrl+S to save your Job.
  2. Press F6, or click Run on the Run tab to
    execute the Job.

    The console displays the exact matches and rejected data in two different
    tables.
    tJoin_15.png


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