Using Stage Variables in PX vs. Server

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
mfavero
Premium Member
Premium Member
Posts: 45
Joined: Thu Jan 16, 2003 1:20 pm
Location: Minneapolis

Using Stage Variables in PX vs. Server

Post by mfavero »

I am having trouble with the values of Stage variables being retained from one row to the next. In Server this always worked, but in PX the variables all seem to be reset to zero or null as each row is processed.

example 2 varables:

VarSave integer(10) initial value 0
Var1 integer(10) initial value 0

In stage variables:
1st VarSave set to Var1
2nd Var1 set to input.column1

2 rows input:

column1
1
2

output
input.column1
VarSave
Var1

results:
1
0
1

nothing wrong with first row

second row results:
2
0
2

VarSave should have retained the 1 from the first row but did not.
I was looking for:

2
1
2
Michael Favero

2852 Humboldt Ave So
Minneapolis, MN 55408
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

The only thing I can think of is that each row is being processed separately in parallel. Therefore each row will read the initial value as 0 at the same time. I would be interested to see what your outputs were when you used more rows, as I would expect to see the VarSave value to start counting up when there are multiple rows processing on the node.

The only way to ensure that all rows are passed through the variables would be to run the transformer in sequential mode rather than parallel.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Was this run on a two-node configuration file, with one row being processed on each?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

ray.wurlod wrote:Was this run on a two-node configuration file, with one row being processed on each?
That is what I was trying to allude to - but couldn't put it as succinctly
vkhandel
Participant
Posts: 35
Joined: Wed Oct 04, 2006 12:12 am
Location: Pune

Post by vkhandel »

The transformer should be executed in the sequential mode, to achieve the desired output.
vmcburney
Participant
Posts: 3593
Joined: Thu Jan 23, 2003 5:25 pm
Location: Australia, Melbourne
Contact:

Post by vmcburney »

You can still use stage variables. For a counter just use some of the PX specific macros that give you the number of threads and thread number. For remembering values just match the partitioning to the key fields, think of it as a multiple instance job, partition by the right field and you can still compare values between rows in a way that makes sense.
mfavero
Premium Member
Premium Member
Posts: 45
Joined: Thu Jan 16, 2003 1:20 pm
Location: Minneapolis

Post by mfavero »

thanks - the problem was indeed that each of the two rows was being processed by a different partition (8 node cfg)

The job only processes 2 rows, so I simply changed it to run in sequential mode.
Michael Favero

2852 Humboldt Ave So
Minneapolis, MN 55408
Post Reply