Page 1 of 1

understanding LastRowInGroup()

Posted: Sat Jan 05, 2013 7:20 am
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

Posted: Sat Jan 05, 2013 7:40 am
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

Posted: Sat Jan 05, 2013 8:39 am
by zulfi123786
pretty nice !!! but just curious how :)

Posted: Sat Jan 05, 2013 9:05 am
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.

Posted: Sat Jan 05, 2013 9:12 am
by zulfi123786
If it is somehow pulling information of upstream tsort operator just wondering what if the source is a sorted sequential file.

Posted: Sat Jan 05, 2013 9:14 am
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".