Transformer Stage variable increment not working

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
Nagalakshmi.Krishna
Participant
Posts: 11
Joined: Sat Feb 10, 2007 12:32 am

Transformer Stage variable increment not working

Post by Nagalakshmi.Krishna »

Hi,
In DS Transformer stage , I use one stage variable STGVAR1 of IINTEGER with starting value 0.And then I use the expression that STGVAR1+1.The values in the output not coming correctly,output I pasted below.Can you help me the reason why it is not incrementing properly?
1
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
12
13
14
.
.
.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

How many nodes is your job running on? More than one, it seems.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Rakesh311
Participant
Posts: 36
Joined: Wed Aug 04, 2010 10:53 pm
Location: Banglore
Contact:

Post by Rakesh311 »

If there are more than one node then
Go to transformer Properties , then Advanced
And then change execution mode to sequential
:D
rAKESH
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Re: Transformer Stage variable increment not working

Post by ray.wurlod »

Nagalakshmi.Krishna wrote:Can you help me the reason why it is not incrementing properly?
No, because both instances of your Transformer stage ARE incrementing correctly. You have two lots of 1 through 20. If you need to preserve the order thereof, add a sort of some kind downstream of the Transformer stage, and use a Sort Merge collection algorithm.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
dxwwq557
Participant
Posts: 16
Joined: Wed Nov 10, 2010 9:19 pm
Location: Chengdu

Post by dxwwq557 »

beacause of the partition, the are two partitions in ur job, u should change the stage property, use sequencial.defualt by parallel.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Or understand why it is happening and deal with or adapt it as Ray notes, rather than force your parallel job to run sequential.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Typically you would use an algorithm such as the following in a transform stage to ensure that you get a single unique number across any number of partitions in your job:

Code: Select all

(@NUMPARTITIONS * ( @INROWNUM - 1)) +  @PARTITIONNUM
Ravi.K
Participant
Posts: 209
Joined: Sat Nov 20, 2010 11:33 pm
Location: Bangalore

Post by Ravi.K »

Here Transformer runs in Parallel Mode. So, records are distributed accordingly to the nodes. To generate Sequence number use the below derivation.

(((@INROWNUM -1) * @NUMPARTITIONS) + @PARTITIONNUM + 1)
Cheers
Ravi K
naveen.p
Participant
Posts: 55
Joined: Sat Nov 21, 2009 5:19 am
Location: Chennai

Post by naveen.p »

Hi,

The Logic is not working correctly.
Its giving the Odd numbers in the Sequence.

Thanks
Naveen
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It IS correct. The even numbers are on the other node.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Ravi.K
Participant
Posts: 209
Joined: Sat Nov 20, 2010 11:33 pm
Location: Bangalore

Post by Ravi.K »

Please confirm whether the sequence number is not generating properly or Sorting order problem.

I checked this logic with "Round Robin Partition" and 4 node configuration file. The logic is working properly and explanation is as follows.

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

Partition 1:

((1 -1) * 4) + 0 +1 = 1

((2 -1) * 4) + 0 +1 = 5

((3 -1) * 4) + 0 +1 = 9

((4 -1) * 4) + 0 +1 = 13

Partition 2:

((1 -1) * 4) + 1 +1 = 2

((2 -1) * 4) + 1 +1 = 6

((3 -1) * 4) + 1 +1 = 10

((4 -1) * 4) + 1 +1 = 14

Partition 3:

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

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

((3 -1) * 4) + 2 +1 = 11

Partition 4:

((1 -1) * 4) + 3 +1 = 4

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

((3 -1) * 4) + 3 +1 = 12

If you face Sorting order problem while collecting the records apply Sort Merge collection method on sequence number.
Cheers
Ravi K
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The first partition number is 0, not 1.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Ravi.K
Participant
Posts: 209
Joined: Sat Nov 20, 2010 11:33 pm
Location: Bangalore

Post by Ravi.K »

I mentioned first Partition number is 0 (Zero) right. Correct me If i coufused you.
Cheers
Ravi K
Post Reply