Surrogate key using only one instance.

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
dsadm_ws
Premium Member
Premium Member
Posts: 65
Joined: Mon Apr 12, 2010 10:30 am

Surrogate key using only one instance.

Post by dsadm_ws »

Have anyone come across this issue.

I am trying to generate a surrogate key using the following logic in my transformer which works fine:

@PARTITIONNUM + ( @NUMPARTITIONS * (@INROWNUM - 1) ) + 1

However, it's using only one 1 instance on 2 nodes(using a dataset in the downstream).

Thanks!
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

So, do you have a question or problem?
- james wiles


All generalizations are false, including this one - Mark Twain.
Gokul
Participant
Posts: 74
Joined: Wed Feb 23, 2005 10:58 pm
Location: Mumbai

Post by Gokul »

Datastage works within nodes. Hence your surrogate key generator logic would work if either it is run one instance or the rows are equally distributed accross all the partitions.


To generate , unique consecutive values in datastage
a> we used to use transformer ( with partition number and number of partitions used) in sequential mode.
or
b> the columne generator in sequential mode.
dsadm_ws
Premium Member
Premium Member
Posts: 65
Joined: Mon Apr 12, 2010 10:30 am

Post by dsadm_ws »

I finally found out what the problem was.

I am running my job on two nodes and before generating the SK i was using Hash Partitioning.

And this was placing all the records in one dataset.

So, tried with round robin, and it worked like a magic.

Thanks Again for all the inputs.
pprakash
Participant
Posts: 3
Joined: Thu Aug 09, 2012 11:14 am
Location: Bangalore

Post by pprakash »

Just want to add, how "Round Robin Partition" works with the logic below;

This will work!

@PARTITIONNUM + (@NUMPARTITIONS * (@INROWNUM - 1)) + 1


i tried with 3 nodes by with 'Round Robin Partitioning'(there are 9 records). Please find the detailed below;



====> @PARTITIONNUM + (@NUMPARTITIONS * (@INROWNUM - 1)) + 1


Partition 1:-

0+(3*(1-1)+1=1
0+(3*(2-1)+1=4
0+(3*(3-1)+1=7

Partition 2:-

1+(3*(1-1)+1=2
1+(3*(2-1)+1=5
1+(3*(3-1)+1=8

Partition 3:-

2+(3*(1-1)+1=3
2+(3*(2-1)+1=6
2+(3*(3-1)+1=9
Prakash S Patil
Capgemini
Post Reply