Vertical Pivot in parallel

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
gssr
Participant
Posts: 243
Joined: Fri Jan 09, 2009 12:51 am
Location: India

Vertical Pivot in parallel

Post by gssr »

Hi all,
I have a input file like this,

Col1,Col2
a,5%
a,6%
a,7%
a,8%


I need the output as
a,5%,6%,7%,8%

Any ideas to solve this issue??

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

Post by ray.wurlod »

Yes, vertical pivot as you identified in your subject line.

First, partition and sort your data by the key column. Use a stable sort, so that the original order of rows is preserved for each key value.

Use a Transformer stage to build lines of output containing each new value in a new field. Use stage variables to preserve the previous value of earlier fields in each row and reinstate those in the output.

Pass that result through a Remove Duplicates stage, preserving the last record of each group.

If you want a comma-delimited file, simply use a Sequential File stage with appropriate format properties set. Otherwise use another Transformer stage to assemble the multiple fields into a comma-separated list.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
gssr
Participant
Posts: 243
Joined: Fri Jan 09, 2009 12:51 am
Location: India

Post by gssr »

We tried the pivot stage ,but it gives only null output...

Do we have to enable any other property in pivot?

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

Post by ray.wurlod »

I did not mention the Pivot stage. The Pivot stage does not support vertical pivot. The PXPivot stage will, in a near future release, but does not currently do so.

I provided a solution that does not involve the Pivot stage, but shows how to accomplish vertical pivot in a parallel job, which is what you sought.
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