Quick Tip: Using Sequences

This quick tip will show how to add a sequence (or row numbers) from the pre-built Talend numeric routines.

The first example will use tRowGenerator to generate 10 rows of random generated data with a row number.

sequence_numbers_tmap_trowgenerator_job

To add a row number, a sequence will be used to count the rows. The sequence function from the built-in numeric routine takes three parameters: a sequence_identifier (string), start_value (integer), and increment value (integer).

In the properties window of tRowGenerator, the column row_number is selected as an Integer, and the Numeric.sqeuence(String,int,int) function is selected from the dropdown.

sequence_numbers_tmap_trowgenerator_properties

This will produce the following output:

The last example will perform a lookup against two tables and outputs matched as well as non-matched rows:

Sequence Numbers Job

The tMap in this job will use an Inner Join model to join the two tables and catch lookup inner join rejects to the non-matched output:

Sequence Numbers tMap

The Expression Builder can be used to add a sequence as a variable in the tMap. This allows the sequence to be re-used with multiple outputs:

Sequence Numbers tMap tMap Var

Sequence Numbers tMap Expression Builder

Finally, the result will add the sequence to both outputs:

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: