Transformer. Would like to hear some ideas.

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
splayer
Charter Member
Charter Member
Posts: 502
Joined: Mon Apr 12, 2004 5:01 pm

Transformer. Would like to hear some ideas.

Post by splayer »

I have a job with a transformer in the middle where rows are coming in. The first column is an integer column starting with 1. I would like to output integer value 1 for the first two rows, 2 for the next two rows, 3 for the next two rows and so on. I can use other stages as well if needed. Any ideas?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Stage variables and a mod() function comes to mind, that and the @INROWNUM system variable. And a single node.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

Int((InLink.TheInteger + 1) / 2)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
splayer
Charter Member
Charter Member
Posts: 502
Joined: Mon Apr 12, 2004 5:01 pm

Post by splayer »

Ray, can you please explain your solution a little?

For @INROWNUM=1 and 2, the key has to be 1.
For @INROWNUM=3 and 4, the key has to be 2 and so on.

Also, 2 is an example number. It could be some other number as well such as 5.
I am having a problem in getting equal number of rows for each key. The first set always has 1 less.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

My solution does not involve @INROWNUM. If you use @INROWNUM it increments on each node, though that would work OK in a two node configuration using Round Robin partitioning if your data were sorted by the integer value to which you referred. But you described your requirement in terms of pairs of rows that include a sequencing integer (1,2,3,4,5,...), so my solution was based on that.

That you have an odd number of rows in your input data, but expect an even number of rows, is therefore curious. Are you trying to read column headings as a data row? Have you specified a partitioning algorithm? Can you guarantee that your source data are made up of pairs of rows?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

N                 1  2  3  4  5  6  7  8  9
Int(N+1)/2)       1  1  2  2  3  3  4  4  5
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply