Identify missing numbers in a source column

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
kumarjit
Participant
Posts: 99
Joined: Fri Oct 12, 2012 7:47 am
Location: Kolkata

Identify missing numbers in a source column

Post by kumarjit »

I have a source column with integer sequence, but the numbers are discontinuous.
Like 2, 4, 5, 6, 8, 25...... and so on.
There is no record count restriction, and I need only those numbers which are missing in the aource sequence as output.
like 1, 3, 7, 9, 10, 11, 12......

Please help.

Regards.
Pain is the best teacher, but very few attend his class..
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You will need sorted data, and you will need to operate in Sequential mode.

Use a Transformer stage. Use stage variables to "remember" the value from the previous row. Use a loop to traverse the interval between that and the current row's value, sending values less than the current row's value to the collection of missed numbers.

You could do the same in a BuildOp if you wanted to code the C++ yourself.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kumarjit
Participant
Posts: 99
Joined: Fri Oct 12, 2012 7:47 am
Location: Kolkata

Post by kumarjit »

Thanks for the help Ray, but since I'm not a premium member, I'm not able to view your message fully.
But I've also tried using the same approach, but I'm not able figure out how to loop through the skipped numbers and retrieve their values.

Regards.
Pain is the best teacher, but very few attend his class..
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

Consider joining as a premium member. It costs less than one restaurant lunch per month.
Choose a job you love, and you will never have to work a day in your life. - Confucius
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Another approach might be to join/lookup with a complete list of numbers, which you could generate within the job. The beginning and end numbers could be provided as job parameters.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kumarjit
Participant
Posts: 99
Joined: Fri Oct 12, 2012 7:47 am
Location: Kolkata

Post by kumarjit »

qt_ky wrote:Consider joining as a premium member. It costs less than one restaurant lunch per month.
:oops: :lol:
Pain is the best teacher, but very few attend his class..
Post Reply