create surrogate key using @INROWNUM/@OUTROWNUM/@NUMPARTITIO

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
cetzhbo
Premium Member
Premium Member
Posts: 38
Joined: Tue Aug 28, 2007 10:20 am

create surrogate key using @INROWNUM/@OUTROWNUM/@NUMPARTITIO

Post by cetzhbo »

Hello Gurus,

How can I create surrogate key using @INROWNUM/@OUTROWNUM/@NUMPARTITIONS/@PARTITIONNUM, which will minimum the number space ? such as " 1, 2,3 " is better, however " 1, 18, 39" is bad.

thanks very much!
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Instead of answering the question, I would like to point out that at Version 8 the transform stage has a surrogate key function that works quite well.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

In other words, it's a bad idea. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
cetzhbo
Premium Member
Premium Member
Posts: 38
Joined: Tue Aug 28, 2007 10:20 am

Post by cetzhbo »

thanks, so please tell me what do these parameter do ? please give me some scenario about that.
cetzhbo
Premium Member
Premium Member
Posts: 38
Joined: Tue Aug 28, 2007 10:20 am

Post by cetzhbo »

thanks, so please tell me what do these parameter do ? please give me some scenario about that.
pksahu
Participant
Posts: 29
Joined: Wed Jul 25, 2007 5:07 am

Generate Sequence number in PX

Post by pksahu »

Yoc can use the below formula:-

@partitionnum+(@inrownum-1) * @NUMPARTITIONS
pksahu
Participant
Posts: 29
Joined: Wed Jul 25, 2007 5:07 am

Generate Sequence number in PX

Post by pksahu »

Yoc can use the below formula:-

@partitionnum+(@inrownum-1) * @NUMPARTITIONS
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

There is a thread in the FAQ forum that discusses how to build a parallel counter in a Transformer using those @ variables. Note that it is very hard to get an unbroken sequence - you usually end up skipping one or more numbers at the very end of the data flow due to imbalanced parallel streams.

For example with four nodes processing 12 rows with key partitioning you can use up these numbers:
1, 5, 9
2, 6, 10, 14
3, 7
4, 8, 11

Round robin partitioning may help but then you face performance worries.
Post Reply