0% found this document useful (0 votes)
12 views11 pages

Joining Two Data Sources With The Tmap

Joining two data sources with the tMap

Uploaded by

rodrigofjorge
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views11 pages

Joining Two Data Sources With The Tmap

Joining two data sources with the tMap

Uploaded by

rodrigofjorge
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

19/04/24, 15:38 PDF Export

Welcome to Qlik Talendâ„¢ Help Center

Joining two data sources with the tMap


component in Talend Studio
2024-04-19

1. Joining two data sources with the tMap component in Talend Studio
1. Creating a Talend Studio project
2. Creating a Job to join data sources
3. Data joining using the tMap component
1. Creating a metadata definition for the tMap component
2. Configuring a tMap component to join two data sources
3. Exporting the results of data joined using a tMap component
4. Configuring joins in the tMap component
1. Configuring a tMap component join model
2. Exporting the results of a tMap component inner join
5. Configuring filters in a tMap component
1. Configuring a tMap component filter by years
2. Configuring a tMap component filter to catch rejects, and exporting to XML

Joining two data sources with the tMap component in Talend Studio
In this tutorial, discover how to join two data sources with the tMap component in Talend Studio.

This tutorial makes use of a .csv file. If you do not have a .csv file, download the following folder and extract the file: movies.zip.

This tutorial also makes use of another delimited file. If you do not have another delimited file, download and extract the following
file: directors.zip.

Creating a Talend Studio project


Creating a project is the first step to using Talend Studio. Projects allow you to better organize your work.

Procedure

1. Select Create a new project.

2. Enter a name for your project.

Example

https://help.talend.com/internal/api/webapp/print/63fa9007-e7c9-4eb6-b641-96f756a2fa2b 1/11
19/04/24, 15:38 PDF Export

TalendDemo

3. Click Create.

4. Click Finish.

Results

Your project opens. You are ready to work in Talend Studio.

Creating a Job to join data sources


Talend Studio projects contain Jobs. In Jobs, you can build workflows through components, which allow you to complete specific
actions.

Before you begin

Select the Integration perspective (Window > Perspective > Integration).

Procedure

1. In Repository, right-click Job Designs.


a. Click Create Standard Job.

2. In the Name field, enter a name.

Example

tMapJoin

3. Optional: In the Purpose field, enter a purpose.

Example

Joining two different data sources in Talend Studio

4. Optional: In the Description field, enter a description.

Example

Using the tMap component to turn two different data sources into one

Tip: Enter a Purpose and Description to stay organized.

5. Click Finish.

Results

The Designer opens an empty Job.

Data joining using the tMap component


The tMap component allows you to transform and route data from single or multiple sources to single or multiple destinations.

Creating a metadata definition for the tMap component

Creating a metadata definition allows you to set up reusable information across all of your components.

Before you begin

This tutorial makes use of a delimited file. If you do not have a delimited file, download and extract the following file: directors.zip.

Procedure

https://help.talend.com/internal/api/webapp/print/63fa9007-e7c9-4eb6-b641-96f756a2fa2b 2/11
19/04/24, 15:38 PDF Export

1. In the Repository, expand Metadata then right-click File delimited and click Create file delimited.

2. In the Name field, enter a name.

Example

directors

3. Optional: In the Purpose field, enter a purpose.

Example
Joining the directors data to the movies database

4. Optional: In the Description field, enter a description.

Example

Reusable shareable directors metadata

Tip: Enter a Purpose and Description to stay organized.

5. Click Next.

6. Click Browse, select the file of your choice in the File Explorer.

7. Optional: Define the parse settings.

https://help.talend.com/internal/api/webapp/print/63fa9007-e7c9-4eb6-b641-96f756a2fa2b 3/11
19/04/24, 15:38 PDF Export

Example

Under File Settings, select your Field Separator and change it, if needed.

Note: The most common Field Separator is ;

Tip: Under Preview, click Refresh Preview to check the parsing results.

8. Click Next.

9. Optional: In the Name field, enter a name.

Example

directorsSchema

10. Update the Schema so it is identical to the structure of the sample file.

Example

Change the name of Column0 to directorID and the name of Column1 to directorName .
Change the Length of directorID to 4 and the Length of directorName to 40 .

11. Click Finish.

Results

In the Repository, under Metadata, you can find and use your metadata.

Configuring a tMap component to join two data sources

The tMap component allows you to transform and route data from single or multiple sources to single or multiple destinations. In
this case, discover how to join two data sources.

About this task

For the sake of demonstration, this tutorial uses two different metadata definitions: movies 0.1 and directors 0.1. To follow this
tutorial, you can:

1. Download the following file: metadata_movies_directors.zip.


2. In the Repository, expand Metadata then right-click File delimited and click Import items.
3. Select Select archive file: then click Browse to select metadata_movies_directors.zip .
4. Select movies 0.1 and directors 0.1.
5. Click Finish.

You can also learn how to create both metadata definitions (see Creating a metadata definition for the tMap component).

Procedure

1. Drag-and-drop the movies 0.1 and directors 0.1 metadata on the Designer.
a. In both cases, select a tFileInputDelimited component.

2. Add a tMap component.

3. Right-click the movies component.


a. Select Row > Main

https://help.talend.com/internal/api/webapp/print/63fa9007-e7c9-4eb6-b641-96f756a2fa2b 4/11
19/04/24, 15:38 PDF Export

b. Click on the tMap component to link the two.

4. Repeat the three previous steps for the directors component.

5. Double-click the tMap component.


You are brought to the tMap component configuration window.

6. On the right side of the screen, click Add output table.

7. Enter a name for your output table.

Example

joinedOutput

8. Click OK.

9. In input table row1, select columns movieID, title, releaseYear, url then drag-and-drop them in output table JoinedOutput.

a. Select column directorID then drag-and-drop it in row2, under Expr. key, next to directorID.

10. In input table row2, select column directorsName then drag-and-drop it in output table JoinedOutput.

11. Click OK.

12. Add a tLogRow component.

13. Right-click the tMap component.


a. Select Row > JoinedOutput.
b. Click on the tLogRow component to link the two.

14. Optional: In the tLogRow component, select the Table Mode.

15. In the Run view, click Run.

Results

The tLogRow component displays a table with the joined data of movies 0.1 and directors 0.1.

Exporting the results of data joined using a tMap component

https://help.talend.com/internal/api/webapp/print/63fa9007-e7c9-4eb6-b641-96f756a2fa2b 5/11
19/04/24, 15:38 PDF Export

Once that you have joined data using the tMap component (see Configuring a tMap component to join two data sources), you can
export it to a delimited file.

Before you begin

You must have joined two data sources (see Configuring a tMap component to join two data sources).

Procedure

1. In the Designer, add a tFileOutputDelimited component.

2. Right-click the tLogRow component.


a. Select Row > Main

b. Click on the tFileOutputDelimited component to link the two.

3. Double-click the tFileOutputDelimited component.

4. In File Name, enter the path and name for the output file.

5. Optional: Select Include Header.

6. In the Run view, click Run.

Results
The joined data is read by the tLogRow component and tFileOutputDelimited component, is displayed on the console and also
exported as a .csv file.

https://help.talend.com/internal/api/webapp/print/63fa9007-e7c9-4eb6-b641-96f756a2fa2b 6/11
19/04/24, 15:38 PDF Export

Configuring joins in the tMap component


You can configure the joining of data in Talend Studio to exclude some of it, following the criteria of your choice.

Configuring a tMap component join model

Many of the films available in the movies.zip file lack director data. You can choose to exclude these films from the joined database
with a tMap component join model.

Before you begin

You must have joined two data sources (see Configuring a tMap component to join two data sources).

Procedure

1. Double-click the tMap component.

2. In input table row2, click tMap settings.


a. Under Value, click Left Outer Join then click the […] button.

b. Select Inner Join.


c. Click OK.

3. In the Run view, click Run.

Results

This time, the exported joined data only includes the films that had a directorID.

Exporting the results of a tMap component inner join

After configuring a tMap component join model (see Configuring a tMap component join model), you can export it to a delimited file.

Before you begin

1. You must have joined two data sources (see Configuring a tMap component to join two data sources).
2. You must also have configured a tMap component join model (see Configuring a tMap component join model).
3. Begin by removing the tLogRow component added previously and connecting the tFileOutputDelimited component to the
tMap component instead.

Procedure

1. Double-click the tMap component.

2. On the right side of the screen, click Add output table.

a. Enter a name for your output table.

Example

joinRejects

b. Click OK.

https://help.talend.com/internal/api/webapp/print/63fa9007-e7c9-4eb6-b641-96f756a2fa2b 7/11
19/04/24, 15:38 PDF Export

3. In input table row1, select all columns then drag-and-drop them in output table joinRejects.

4. In output table joinRejects, click tMap settings.


a. Under Catch lookup inner join reject, click [...].
b. Select true.
c. Click OK.

5. In the Designer, add a tFileOutputDelimited component.

6. Right-click the tMap component.


a. Select Row > JoinRejects.

b. Click on the tFileOutputDelimited component to link the two.

7. Double-click the tFileOutputDelimited component.

8. In File Name, enter the path and name for the output file.

9. Optional: Select Include Header.

https://help.talend.com/internal/api/webapp/print/63fa9007-e7c9-4eb6-b641-96f756a2fa2b 8/11
19/04/24, 15:38 PDF Export

10. In the Run view, click Run.

Results
Talend Studio exports two files: one with films that have a directorID, and who that director is, and another with the movies without
a directorID.

Configuring filters in a tMap component


The tMap component allows you to transform and route data from multiple sources to a single destination. You can also configure
numeric or text filters to sort your data.

Configuring a tMap component filter by years

The tMap component provides many possibilities of joining and filtering your data, including numerically.

About this task

For the sake of demonstration, this tutorial uses metadata definition: movies 0.1. To follow this tutorial, you can:

1. Download the following file: metadata_movies_directors.zip.


2. In the Repository, expand Metadata then right-click File delimited and click Import items.
3. Select Select archive file: then click Browse to select metadata_movies_directors.zip .
4. Select movies 0.1.
5. Click Finish.

You can also learn how to create a metadata definition (see Creating a metadata definition for the tMap component).

Procedure

1. Drag-and-drop the movies 0.1 metadata on the Designer.


a. Select a tFileInputDelimited component.

2. Add a tMap component.

3. Right-click the movies component.


a. Select Row > Main
b. Click on the tMap component to link the two.

4. Double-click the tMap component.


You are brought to the tMap component configuration window.

5. On the right side of the screen, click Add output table.

a. Enter moviesFromThe90s .
b. Click OK.

6. In input table row1, select all columns then drag-and-drop them in output table moviesFromThe90s.

7. In output table moviesFromThe90s, click Enable/disable expression filter.


a. Drag-and-drop the releaseYear column in the expression filter field of output table moviesFromThe90s.
You get the following expression: row1.releaseYear .
b. Enter >=1990 after row1.releaseYear .

https://help.talend.com/internal/api/webapp/print/63fa9007-e7c9-4eb6-b641-96f756a2fa2b 9/11
19/04/24, 15:38 PDF Export

Results

You have configured a numeric filter in the tMap component, allowing you to automatically sort a category of data.

What to do next

Create another output table: moviesFromThe80s. You can easily create a double condition by using the Java && operator (AND):
row1.releaseYear >=1980 && row1.releaseYear <1990 .

Configuring a tMap component filter to catch rejects, and exporting to XML

You must have configured a tMap component filter by years (see Configuring a tMap component filter by years).

Procedure

1. Double-click the tMap component.

2. On the right side of the screen, click Add output table.

a. Enter a name.

Example

moviesBefore80s

b. Click OK.

3. In input table row1, select all columns then drag-and-drop them in output table moviesBefore80s.

4. In output table moviesBefore80s, click tMap settings.


a. In the Value field of Catch output reject, click [...].
b. Select true.
c. Click OK.

https://help.talend.com/internal/api/webapp/print/63fa9007-e7c9-4eb6-b641-96f756a2fa2b 10/11
19/04/24, 15:38 PDF Export

5. Add a tFileOutputXML component for each of the output tables.


a. Right-click the tMap component.
b. Link the tMap component to each of the output components.

Example

Select Row > moviesBefore80s.

6. Double-click each tFileOutputXML component.


a. In File Name, enter the path and name for the output file.

Example

moviesBefore80s.xml

7. In the Run view, click Run.

Results

The Catch output reject Property collects all rows of data which do not match either of the other two conditions, meaning all movies
from before 1980. In customers_unordered.csv , there is only one: Agnès Varda's Cleo from 5 to 7.

https://help.talend.com/internal/api/webapp/print/63fa9007-e7c9-4eb6-b641-96f756a2fa2b 11/11

You might also like