Transposing input row into multiple rows

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
mouthou
Participant
Posts: 208
Joined: Sun Jul 04, 2004 11:57 pm

Transposing input row into multiple rows

Post by mouthou »

Hi All,

I have a requirement to split each incoming row into 25 output rows. But those 25 output rows need to be created based on the 25 columns in each input row. This may look like pivoting but the difficulty is each such output row is to be created only if there is a valid value in the source columns.

Obvious solution could be to use a Transformer to find the length of the trimmed input char columns and if length > 0, then create a row. But I am concerned about creating 25 output links out of a Transformer. Please let me know if there is any other alternative or any length comparison facility in pivot stage itself. Appreciate your thoughts.


source file
----------------
cust id | src_col1| src_col2 |src_col3|.....|src_col18|...|src_col25
123 |1111 |<here blank spaces>|3333 |.....|1818 |...|2525


target DB
-----------
cust id | src_col
123 | 1111
123 | 3333
123 | 1818
123 | 2525


Thanks
Thomas.B
Participant
Posts: 63
Joined: Thu Apr 09, 2015 6:40 am
Location: France - Nantes

Post by Thomas.B »

Did you try to use a transformer (or a filter) to validate the rows on the output link of the pivot stage?
Otherwise you can pivot the data using a looping transformer with only 2 input fields (concatenate all the "src_col" fields) and use the field() function to process the columns one by one.
BI Consultant
DSXConsult
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

Looping transformer as mentioned, plus a constraint to filter out the records with invalid values.
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 »

I'd be quite happy to specify 25 output links.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
mouthou
Participant
Posts: 208
Joined: Sun Jul 04, 2004 11:57 pm

Re: Transposing input row into multiple rows

Post by mouthou »

Thanks everyone for the responses. In a way, the approaches using a Transformer only inevitably (be it 25 links or pivot or looping).

I went ahead with Pivot & Transformer combination though.

As Ray said, Transformer with 25 links could have worked well but it seemed to make the design bulky in addition to the internal code generation for that Transformer. This design will be really good as it creates a row in the output link only there is value. A similar option I was looking for without a Transformer!
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Re: Transposing input row into multiple rows

Post by ray.wurlod »

mouthou wrote:A similar option I was looking for without a Transformer!
Why?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

Maybe due to the urban legend that Transformer stage is slower or used to be slower than other stages... :?:
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 »

The "used to be" part is not an urban legend. It was true. It was fixed.
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