understanding LastRowInGroup()

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
zulfi123786
Premium Member
Premium Member
Posts: 730
Joined: Tue Nov 04, 2008 10:14 am
Location: Bangalore

understanding LastRowInGroup()

Post by zulfi123786 »

Below is taken from help window of Datastage
If the argument specified is the secondary or other sorted key, then LastRowInGroup() returns TRUE if the value of the specified column is about to change, or if any of its higher level of key columns are about to change. For example, if the primary sorted column is Col1 and the secondary sorted column is Col2, then LastRowInGroup(Col2) returns true when either the value in Col2 is about to change, or the value in Col1 is about to change. Therefore it can return true when Col2 is not about to change, but Col1 is, because Col1 is a higher level sorted key than Col2.

If the data is sorted on multiple columns and LastRowInGroup() is applied to secondary sort column how will transfomer know which is the primary sort column unless specified as an argument as to what is the sort hierarchy of columns ?

Thanks
- Zulfi
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

Pretty nice feature wouldn't you say :) .

I don't have any internal knowledge as to how that function is coded, but presumably it is smart enough to "see" the last upstream tsort operator and the sort order that was specified therein.

Mike
zulfi123786
Premium Member
Premium Member
Posts: 730
Joined: Tue Nov 04, 2008 10:14 am
Location: Bangalore

Post by zulfi123786 »

pretty nice !!! but just curious how :)
- Zulfi
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

This is also in the help, just before your text:
The data must be sorted in the job, so that the Transformer stage can detect that it is sorted. If the data is sorted before being input to the job, you can include a dummy Sort stage and set the stage's Sort Key property to Don't Sort (previously sorted) for every column on which the data was previously sorted.
Just confirms the what, the how would be some IBM secret sauce.
-craig

"You can never have too many knives" -- Logan Nine Fingers
zulfi123786
Premium Member
Premium Member
Posts: 730
Joined: Tue Nov 04, 2008 10:14 am
Location: Bangalore

Post by zulfi123786 »

If it is somehow pulling information of upstream tsort operator just wondering what if the source is a sorted sequential file.
- Zulfi
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Then, as noted in the docs, you'll have to specifiy how it is sorted "so that the Transformer stage can detect that it is sorted". And as noted that would be via a Sort stage set to "Don't Sort".
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply