
Warning
This component will be available in the Palette of the studio on the condition that you have subscribed to
one of the Talend solutions with Big
Data.
Component family |
Big Data / Hadoop |
|
Function |
This component allows you to perform join of two files based on |
|
Purpose |
The tPigJoin component is used to |
|
Basic settings |
Schema and Edit |
A schema is a row description. It defines the number of fields to be processed and passed on Since version 5.6, both the Built-In mode and the Repository mode are Click Edit schema to make changes to the schema. If the
NoteTo make this component work, two schemas must be set: the |
|
|
Built-in: The schema will be |
|
|
Repository: The schema already |
Reference file |
Schema and Edit |
A schema is a row description. It defines the number of fields to be processed and passed on Since version 5.6, both the Built-In mode and the Repository mode are Click Edit schema to make changes to the schema. If the
NoteTo make this component work, two schemas must be set: the |
|
|
Built-in: The schema will be |
|
|
Repository: The schema already |
|
Filename |
Fill in the path of the Lookup |
Field Separator |
Enter character, string or regular expression to separate fields for the transferred |
|
|
Join key |
Click the plus button to add lines to set the Join key for Input |
|
Join mode |
Select a join mode from the list:
inner-join: Select this mode to
left-outer-join: Select this mode
right-outer-join: Select this mode
full-outer-join: Select this mode For further information about inner join and outer join, |
Advanced settings |
Optimize the join |
Select this check box to optimize the performance of joins using http://pig.apache.org/docs/r0.8.1/piglatin_ref1.html#Specialized+Joins |
|
Use partitioner |
Select this check box to specify the Hadoop Partitioner that http://hadoop.apache.org/docs/r2.2.0/api/org/apache/hadoop/mapred/Partitioner.html |
|
Increase parallelism |
Select this check box to set the number of reduce tasks for the |
|
tStatCatcher Statistics |
Select this check box to gather the Job processing metadata at the |
Global Variables |
ERROR_MESSAGE: the error message generated by the A Flow variable functions during the execution of a component while an After variable To fill up a field or expression with a variable, press Ctrl + For further information about variables, see Talend Studio |
|
Usage |
This component is commonly used as intermediate step together with |
|
Prerequisites |
The Hadoop distribution must be properly installed, so as to guarantee the interaction
For further information about how to install a Hadoop distribution, see the manuals |
|
Log4j |
The activity of this component can be logged using the log4j feature. For more information on this feature, see Talend Studio User For more information on the log4j logging levels, see the Apache documentation at http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Level.html. |
|
Limitation |
Knowledge of Pig scripts is required. |
This scenario describes a four-component Job that combines data of an input file and a
reference file that matches a given join key, removes unwanted columns, and then saves
the final result to a local file.
The main input file contains the information about people’s IDs, first names, last
names, group IDs, and salaries, as shown below:
1 2 3 4 5 6 7 8 9 10 |
1;Woodrow;Johnson;3;1013.39 2;Millard;Monroe;2;8077.59 3;Calvin;Eisenhower;3;6866.88 4;Lyndon;Wilson;3;5726.28 5;Ronald;Garfield;2;4158.58 6;Rutherford;Buchanan;3;2897.00 7;Calvin;Coolidge;1;6650.66 8;Ulysses;Roosevelt;2;7854.78 9;Grover;Tyler;1;5226.88 10;Bill;Tyler;2;8964.66 |
The reference file contains only the information of group IDs and group names:
1 2 |
1;group_A 2;group_B |
-
Drop the following components from the Palette to the design workspace: tPigLoad, tPigJoin,
tPigFilterColumns, and tPigStoreResult. -
Connect these components in a series using Row >
Pig Combine connections.
Loading the main input file
-
Double-click tPigLoad to open its
Basic settings view. -
Click the […] button next to Edit schema to open the [Schema] dialog box.
-
Click the [+] button to add columns, name
them and define the column types according to the structure of the input
file. In this example, the input schema has five columns: id (integer), firstName (string), lastName (string), groupId (integer), and salary (double).Then click OK to validate the setting and
close the dialog box. -
Click Local in the Mode area.
-
Select PigStorage from the Load function list.
-
Fill in the Input file URI field with the
full path to the input file, and leave the rest of the setting as they
are.
Loading the reference file and setting up an inner join
-
Double-click tPigJoin to open its
Basic settings view. -
Click the […] for the main schema to
open the [Schema] dialog box. -
Check that input schema is correctly retrieved from the preceding
component. If needed, click the [->>]
button to copy all the columns of the input schema to the output schema. -
Click the [+] button under the output
panel to add new columns according to the data structure of the reference
file, groupId_ref (integer) and groupName (string) in this example. Then click
OK to close the dialog box. -
Click the […] for the schema lookup
flow to open the [Schema] dialog
box. -
Click the [+] button under the output
panel to add two columns: groupId_ref
(integer) and groupName (string), and
then click OK to close the dialog
box. -
In the Filename field, specify the full
path to the reference file. -
Click the [+] button under the Join key table to add a new line, and select
groupId and groupId_ref
respectively from the Input and Lookup lists to match data from the main input
flow with data from the lookup flow based on the group ID. -
From the Join Mode list, select inner-join.
Defining the final output schema and the output file
-
Double-click tPigFilterColumns to open
its Basic settings view. -
Click the […] button next to Edit schema to open the [Schema] dialog box.
-
From the input schema, select the columns you want to include in your
result file by clicking them one after another while pressing the Shift key, and click the
[->] button to copy them to the output schema. Then, click
OK to validate the schema setting and
close the dialog box.In this example, we want the result file to include all the information
except the group IDs. -
Double-click tPigStoreResult to open its
Basic settings view. -
Click Sync columns to retrieve the schema
structure from the preceding component. -
Fill in the Result file field with the
full path to the result file, and select the Remove
result file directory if exists check box. -
Select PigStorage from the Store function list, and leave rest of the
settings as they are.