Fork-join with condition

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
jeisma
Participant
Posts: 18
Joined: Mon Mar 20, 2017 12:19 pm

Fork-join with condition

Post by jeisma »

Hi,

This simple programming task made me spent couple of days trying to implement in ds, to no avail :oops:

If I have this data:

Code: Select all

col1   col2
id1         5
id2         0
id3         0
id4         0
id5         0


I'd lke to output to become just one row, where col2 is the last non zero value read.

Code: Select all

col1     col2
row          5
My approach is compare current_value versus previous_value, so if current_value is zero, it take previous_value. Given the data above, my output becomes:

Code: Select all

col1   col2
id1         5
id2         0
id3         5
id4         0
id5         5


To think that I still need to hurdle the joining the data into one row. :(

Any ideas how to solve the above problems?


TIA!
thompsonp
Premium Member
Premium Member
Posts: 205
Joined: Tue Mar 01, 2005 8:41 am

Post by thompsonp »

What are you hoping to see in col1 on the output?

If it's just the col1 value from the row that had the last non zero value in col2 then it's straightforward.

Filter out all the rows where col2 is zero, then take the last row (tail).
Post Reply