July 30, 2023

tELTMysqlMap – Docs for ESB 7.x

tELTMysqlMap

Uses the tables provided as input to feed the parameter in the built statement. The
statement can include inner or outer joins to be implemented between tables or between one
table and its aliases.

The three ELT Mysql components are closely related, in
terms of their operating conditions. These components should be used to handle Mysql DB
schemas to generate Insert statements, including clauses, which are to be executed in
the DB output table defined.

tELTMysqlMap helps to graphically build the SQL
statement using the table provided as input.

tELTMysqlMap Standard properties

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

The Standard
tELTMysqlMap component belongs to the ELT family.

The component in this framework is available in all Talend
products
.

Basic settings

Use an existing connection

Select this check box and in the Component List click the relevant connection component to
reuse the connection details you already defined.

Note: When a Job contains the parent Job and the child Job, if you
need to share an existing connection between the two levels, for example, to share the
connection created by the parent Job with the child Job, you have to:

  1. In the parent level, register the database connection
    to be shared in the Basic
    settings
    view of the connection component which creates that very database
    connection.

  2. In the child level, use a dedicated connection
    component to read that registered database connection.

For an example about how to share a database connection
across Job levels, see

Talend Studio
User Guide
.

ELT Mysql Map editor

The ELT Map editor allows you to define the output schema as well as
build graphically the SQL statement to be executed. The column names of
schema can be different from the column names in the database.

Style link

Select the way in which links are displayed.

Auto: By default, the links between the
input and output schemas and the Web service parameters are in the form
of curves.

Bezier curve: Links between the schema
and the Web service parameters are in the form of curve.

Line: Links between the schema and the
Web service parameters are in the form of straight lines.

This option slightly optimizes performance.

Property type

Either Built-in or Repository.

 

Built-in: No property data stored
centrally.

 

Repository: Select the Repository
file where Properties are stored. The following fields are pre-filled in
using fetched data.

Host

Database server IP address.

Port

Listening port number of DB server.

Database

Name of the database.

Username and Password

DB user authentication data.

To enter the password, click the […] button next to the
password field, and then in the pop-up dialog box enter the password between double quotes
and click OK to save the settings.

Advanced settings

Additional JDBC Parameters

Specify additional JDBC parameters for the
database connection created.

This property is not available when the Use an existing connection
check box in the Basic settings view is selected.

tStatCatcher 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

tELTMysqlMap is used along with a
tELTMysqlInput and tELTMysqlOutput. Note that the Output link to
be used with these components must correspond strictly to the syntax of
the table name.

Note:

The ELT components do not handle actual data flow but only schema
information.

Dynamic settings

Click the [+] button to add a row in the table
and fill the Code field with a context
variable to choose your database connection dynamically from multiple
connections planned in your Job. This feature is useful when you need to
access database tables having the same data structure but in different
databases, especially when you are working in an environment where you
cannot change your Job settings, for example, when your Job has to be
deployed and executed independent of Talend Studio.

The Dynamic settings table is
available only when the Use an existing
connection
check box is selected in the Basic settings view. Once a dynamic parameter is
defined, the Component List box in the
Basic settings view becomes unusable.

For examples on using dynamic parameters, see Reading data from databases through context-based dynamic connections and Reading data from different MySQL databases using dynamically loaded connection parameters. For more information on Dynamic
settings
and context variables, see Talend Studio
User Guide.

Aggregating table columns and filtering

This scenario describes a Job that gathers together several input DB table schemas and
implementing a clause to filter the output using an SQL statement.

Building a Job

  1. Add the following components from the Palette onto the design workspace. Label these components to
    best describe their functionality.

    • three tELTMysqlInput
      components
    • a tELTMysqlMap
    • a tELTMysqlOutput
  2. Double-click the first tELTMysqlInput
    component to display its Basic settings
    view.

    tELTMysqlMap_1.png

  3. Select Repository from the Schema list, click the three dot button preceding
    Edit schema, and select your DB
    connection and the desired schema from the Repository
    Content
    dialog box.

    The selected schema name appears in the Default
    Table Name
    field automatically.

    In this use case, the DB connection is
    Talend_MySQL
    and
    the schema for the first input component is owners.

  4. Set the second and third tELTMysqlInput
    components in the same way but select cars and resellers respectively as their schema names.

    Note: In this use case, all the involved schemas are stored in
    the Metadata node of the Repository tree view for easy retrieval. For
    further information concerning metadata, see
    Talend Studio User
    Guide
    .

    You can also select the three input
    components by dropping the relevant schemas from the Metadata area onto the design workspace
    and double-clicking tELTMysqlInput from the Components dialog box. Doing so allows you to skip the
    steps of labeling the input components and defining their schemas
    manually.

  5. Connect the three tELTMysqlInput
    components to the tELTMysqlMap component
    using links named following strictly the actual DB table names: owners, cars and resellers.
  6. Connect the tELTMysqlMap component to
    the tELTMysqlOutput component and name
    the link agg_result, which is the name of the database
    table you will save the aggregation result to.
  7. Click the tELTMysqlMap component to
    display its Basic settings view.

    tELTMysqlMap_2.png

  8. Select Repository from the Property Type list, and select the same DB
    connection that you use for the input components.

    All the database details are automatically retrieved.

    Tip: Leave all the other settings as they are.

  9. Double-click the tELTMysqlMap component
    to launch the ELT Map editor to set up joins between the input tables and define
    the output flow.

    tELTMysqlMap_3.png

  10. Add the input tables by clicking the green plus button at the upper left corner
    of the ELT Map editor and selecting the relevant table names in the Add a new alias dialog box.
  11. Drop the ID_Owner column from the owners table to the corresponding column of
    the cars table.
  12. In the cars table, select the Explicit join check
    box in front of the ID_Owner column.

    As the default join type, INNER
    JOIN
    is displayed on the Join list.

  13. Drop the ID_Reseller column from the cars table to the corresponding column of
    the resellers table to set up the second join, and define the join as an inner
    join in the same way.
  14. Select the columns to be aggregated into the output table, agg_result.
  15. Drop the ID_Owner, Name, and ID_Insurance columns from the owners table to the
    output table.
  16. Drop the Registration, Make, and Color columns from the cars table to the
    output table.
  17. Drop the Name_Reseller and City columns from the resellers table to the output
    table.

    With the relevant columns selected, the mappings are displayed in yellow and
    the joins are displayed in dark violet.
  18. Set up a filter in the output table. Click the Add
    filter row
    button on top of the output table to display the
    Additional clauses expression field,
    drop the City column from the resellers table to the expression field, and complete a WHERE clause
    that reads resellers.City ='Augusta'.

    tELTMysqlMap_4.png

  19. Click the Generated SQL Select query tab
    to display the corresponding SQL statement.

    tELTMysqlMap_5.png

  20. Click OK to save the ELT Map
    settings.
  21. Double-click the tELTMysqlOutput
    component to display its Basic
    settings
    view.

    tELTMysqlMap_6.png

  22. Select an action from the Action on data
    list as needed.
  23. Select Repository as the schema type,
    and define the output schema in the same way as you defined the input schemas.
    In this use case, select agg_result as the output schema,
    which is the name of the database table used to store the mapping result.

    Note: You can also use a built-in output schema and retrieve
    the schema structure from the preceding component; however, make sure that
    you specify an existing target table having the same data structure in your
    database.
    Tip: Leave all the other settings as they are.

Running the Job

  1. Save your Job.
  2. Press F6 to launch it.

    All selected data is inserted in the agg_result table
    as specified in the SQL statement.

    tELTMysqlMap_7.png

Mapping date using using an Alias table

This scenario describes a Job that maps information from two input tables
and an alias table, serving as a virtual input table, to an output table. The employees table contains employees’ IDs, their department numbers,
their names, and the IDs of their respective managers. The managers are also considered
as employees and hence included in the employees table. The dept table contains the department information. The alias table
retrieves the names of the managers from the employees table.

tELTMysqlMap_8.png

Building a Job

  1. Drop two tELTMysqlInput components, a
    tELTMysqlMap component, and a
    tELTMysqlOutput component to the
    design workspace, and label them to best describe their functionality.
  2. Double-click the first tELTMysqlInput
    component to display its Basic settings
    view.

    tELTMysqlMap_9.png

  3. Select Repository from the Schema list, and define the DB connection and
    schema by clicking the three dot button preceding Edit
    schema
    .

    The DB connection is
    Talend_MySQL
    and
    the schema for the first input component is employees.

    Note:

    In this use case, all the involved schemas are stored in
    the Metadata node of the
    Repository tree view for easy
    retrieval. For further information concerning metadata, see
    Talend Studio User
    Guide
    .

  4. Set the second tELTMysqlInput component
    in the same way but select dept as its schema.
  5. Double-click the tELTMysqlOutput
    component to display its Basic settings
    view.

    tELTMysqlMap_10.png

  6. Select an action from the Action on data
    list as needed, Insert in this use
    case.
  7. Select Repository as the schema type,
    and define the output schema in the same way as you defined the input schemas.
    In this use case, select result as the output schema,
    which is the name of the database table used to store the mapping result.

    The output schema contains all the columns of the input schemas plus a ManagerName column.

    Note: Leave all the other parameters as they are.

Connecting the components

  1. Connect the two tELTMysqlInput
    components to the tELTMysqlMap component
    using Link connections named strictly
    after the actual input table names, employees and dept in this use case.
  2. Connect the tELTMysqlMap component to
    the tELTMysqlOutput component using a
    Link connection. When prompted, click
    Yes to allow the ELT Mapper to
    retrieve the output table structure from the output schema.
  3. Click the tELTMysqlMap component and
    select the Component tab to display its
    Basic settings view.

    tELTMysqlMap_11.png

  4. Select Repository from the Property Type list, and select the same DB
    connection that you use for the input components.

    All the DB connection details are automatically retrieved.

    Note: Leave all the
    other parameters as they are.

Configuring the Job

  1. Click the three-dot button next to ELT Mysql Map
    Editor
    or double-click the tELTMysqlMap component on the design workspace to launch the
    ELT Map editor.

    With the tELTMysqlMap component
    connected to the output component, the output table is displayed in the output
    area.
  2. Add the input tables, employees and dept, in the input area by clicking the
    green plus button and selecting the relevant table names in the Add a new alias
    dialog box.
  3. Create an alias table based on the employees table by selecting employees from
    the Select the table to use list and typing in Managers in the Type in a valid
    alias field in the Add a new alias dialog box.

    tELTMysqlMap_12.png

  4. Drop the DeptNo column from the employees table to the dept table.
  5. Select the Explicit join check box in
    front of the DeptNo column of the dept table to set up an inner join.
  6. Drop the ManagerID column from the employees table to the ID column of the
    Managers table.
  7. Select the Explicit join check box in
    front of the ID column of the Managers table and select LEFT OUTER
    JOIN
    from the Join list
    to allow the output rows to contain Null values.

    tELTMysqlMap_13.png

  8. Drop all the columns from the employees table to the corresponding columns of
    the output table.
  9. Drop the DeptName and Location columns from the dept table to the corresponding
    columns of the output table.
  10. Drop the Name column from the Managers table to the ManagerName column of the
    output table.

    tELTMysqlMap_14.png

  11. Click on the Generated SQL Select query
    tab to display the SQL query statement to be executed.

    tELTMysqlMap_15.png

Running the Job

  1. Save your Job.
  2. Press F6 to run it.

    The output database table result contains all the
    information about the employees, including the names of their respective
    managers.

    tELTMysqlMap_16.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