mobileNavlogo
headerlogo

Head Tail and Sample in DataStage

31 March, 2021

Ratings

Related Blogs

 

Head Tail and Sample

Head

Head is a debug stage that picks top ‘n’  records from all the nodes  (or)Specific nodes.

  Head  

Head 7 properties

Rows

All rows  (After skip)  = false

Number of rows (preparation) = 2

  • Available properties period preparation skip the preparation
  • Partitions

All Partitions = True

Click on output 7Do the mapping 7Ok  

Do you want to master DataStage? Then enrol in "DataStage Training" This course will help you to master DataStage

In the output:-

The top 2 records will be displayed

[In Sequential file, if we load multiple files, then set

S.F 7properties àoptions 7 Keep file partitions = True]

Tail

Tail is a debug stage that picks bottom ‘n’ records from all nodes or specific nodes

  • Tail
  •  properties
  •  Rows

Number of rows (preparation) = 2   Partitions

All Partitions = false

Click on output mapping  

Display last 2 records

Ex:- Suppose that we have 60 records and we need to display the 30th record to the 40th record.

Sol:  In Head 7 properties 7Set No. of row  (per partition) = 40

In Tail7Properties7Set No. of row  (per partition) = 10

  Display records  

Sample

The sample is also a debug stage, which operates in ‘2’ Modes  

  • Period 7 1 input and 1 output
  • Percentage 7 1 input and 1 output

Period is interval of records if period = 2 , displays 2,4, 6,8,10……….

Sample

Properties

Options

Per cent =?

Out click number =?

Sample mode – period /per cent

If period

  Options

Period (per partition)  =2 7 output à Mapping 7 ok

If per cent

Since it has multiple outputs it follows the link to order.

Percent

Options

Percent = 50

Output link Number =

Percent = 25

Output link number =

Sample Mode = percent 7 Click on link ordering (To know the link label) 7

0       t2

1  ↔  t1

2    t3

Now assign these values accordingly in output – link number

     ↓

Click on output

     ↓

Perform the mapping  fx t1, t2, t3

     ↓

Ok  

Peek:- (Multipurpose)

Peek is a debug stage that can be used for

  • Send the records to the logs
  • Make the Source to Multiple copies (can be used as “copy” stage)
  • Used as STUB stage (place holder)

Log 7 Detailed info abt execute

  Peek    

S.F 7 load peek 7 we can view data here 7   

Properties

   ↓

No. of Records = 5  (per partition) (All the 5

   ↓

Records will be sent to the job log)7

   ↓

Peek Records output Mode = Job log7

   ↓

ok   7After Compilation and Run, Go to “Tool”

  • Tool

      ↓

Run Director

      ↓

Select the job

      ↓

Click on job log Symbol

  • In that, we can see 3 types of colours
  • Green – ok
  • Red – Error
  • Yellow – Warning

To clear the Warnings

Right click on Warning (or) double click 7 Warning   Message will be displayed 7Identify the Warning and try to Eliminate them

Note:-   “Missing” record delimiter “/r/n”  (one type of error) (it means Mismatch)

In which Cases, we have to put a “Reject link” and capture the mismatched data

Message Handing

Right-click on  Yellow Warning 7Add to Message Handler 7 Actions (Suppress / Demote) 7Add Ruler 7ok Warning get converted into Information

Filtering:-

Job 7Right-click 7filter (put the options)

7click on job name 7 we can see 5 records  

Peek properties 

Rows  all the rows  (after skip)   = false                                         properties

Number of records  (per partition) = columns                              period (per partition)

Peek all input  columns = True partitions                                      Skip  (per partition)

All partition = true

Options

Peek Records output Mode == Joblog                                        properties

(or) output                                                                                    Deli meter string

Show column Name = True

Ex:

Suppose we want to see the data at each stage then attach a peek

Stage to each Transformation :   Oracle --- Sort 7 Transformation1 7Transformation 2 7Transformation 3 7Data set

                         ↓                      ↓                    ↓

Peek 1                                               peek 2                                        peek 3  

  • To select only particular columns:-

Peek can send data to logs, peek can also send required columns to the logs.

Peek

For Ex:-  If we have a table that will field and 9 records, and wanted to display only 2 fields with 9 records.

Peek 7 properties 7 No. of Records = 4 (per partition) 7columns 7Input column to peek = c id, Input column to peek = State, Peek all input columns = false 7 ok 7After compile and Run Tools 7 Run Director 7Select job 7 log 7Event Detail window appears

Output :-  peek 1, 0: cid 1 , state AP

If we want to display only records without displaying column names

Columns Show column Name = false  

  • Make the source into Multiple copies

  Display records      

7 Peek 7 properties 7 No. of Records = 5  7 peek Records output Mode = job log 7Go to “output” tab 7 Map the data (l1, l2, l3) 7 ok

7Compile and run the job Here peek Stage ads as copy stage and copies, The data as it is to the 3 data sets.

If we set  peek Record output Mode = output, then

Peek record      

Peek 7 properties 7 No. of Records = 5 7 peek Record output Mode = output 7Output 7 Map the data 7 ok  

When we set peek Record output Mode = output, then the peak output

That is 5 records will be displayed in one of the .ds files, and in the other .ds file, All records will be displayed.  

In Data set 3 7 view data 7 we can see 5 records ( that is peek data)

7Suppose the client needs only rejected, but not output, thenHere we use peek as the output stage

  Dead end  

Here peek is used as STUB Stage, a place holder to store the data.

For an in-depth understanding of DataStage click on

About Author
Authorlogo
Name

TekSlate

Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills .