Head Stage Example

The Head Stage is one of a Development/Debug stage.

The Head Stage can have a single input link and a single output link and selects the first N rows from each partition of an input data set and copies the selected rows to an output data set. You determine which rows are copied by setting properties which allow you to specify:

· The number of rows to copy

· The partition from which the rows are copied

· The location of the rows to copy

· The number of rows to skip before the copying operation begins

Example:

In below example we are going to extract first N number of Employees details in a target Dataset.

Follow below steps:

Design you job same as shown below:

1 4 - Head Stage Example

Input Data:

Here, we are having some Employee data in a sequential file as an input.

Input 1 - Head Stage Example

Open the Properties window of Head stage by double click on it or select properties from drop down by Right Clickàselect Properties to open it and Under Output tab, select Properties tab and select below options ‘Number of Rows=4’ to extract 4 records each on defined partitions.

2 4 - Head Stage Example

Select the Mapping option under Output tab and provide the source to target mapping by drag and drop required columns to the target.

3 3 - Head Stage Example

Save the job and Compile and run the job. After successful job run we can see the rows has been generated in target dataset.

4 2 - Head Stage Example

Output Data:

After successful job run, View the data from the target Dataset. Here we can see top 8 records from the input file has been pulled and inserted to the target dataset. ( We have specified No. of records=4, and we have 2 node configuration, hence we got 4×2=8 records as output.)

output 4 rec - Head Stage Example

Open the Properties window of Head stage by double click on it or select properties from drop down by Right Clickàselect Properties to open it and Under Output tab, select Properties tab and select below options ‘Number of Rows=4’ to extract 4 records on defined partitions ‘Partition=1’ as below.

5 3 - Head Stage Example

Save the job and Compile and run the job. After successful job run we can see the rows has been generated in target dataset. (Have a look on the job statistics, only 4 records on Partition 1 has been pulled to target.)

6 2 - Head Stage Example

Output Data:

After successful job run, View the data from the target Dataset. Here we can see top 4 records from the input file on Partition1 has been pulled and inserted to the target dataset.

output partition 1 - Head Stage Example