How to achieve other than Pivot

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
pradeep_nov18
Participant
Posts: 92
Joined: Wed Mar 05, 2008 4:09 am
Location: chennai
Contact:

How to achieve other than Pivot

Post by pradeep_nov18 »

Hi Experts,

I have requirement


Input:

a b c
1 10 20
2 30 40

Output Required:

a Computed_col(E)
1 10
1 20
2 30
2 40

How to achieve these other than pivot stage.

Can anyone help me on this?

Thanks in advance for your reply! [/b]
pradeep.v
mahadev.v
Participant
Posts: 111
Joined: Tue May 06, 2008 5:29 am
Location: Bangalore

Post by mahadev.v »

Any specific reason why you don't want to use the Pivot stage? A custom Build Op stage can be used, but involves a lot of coding.
"given enough eyeballs, all bugs are shallow" - Eric S. Raymond
pradeep_nov18
Participant
Posts: 92
Joined: Wed Mar 05, 2008 4:09 am
Location: chennai
Contact:

Hi

Post by pradeep_nov18 »

mahadev.v wrote:Any specific reason why you don't want to use the Pivot stage? A custom Build Op stage can be used, but involves a lot of coding.
Hi Mahadev,

No reason behind that :o

Whats that Custom Op?

Any Idea how we can perform in Transformer.

Thanks for the reply :)
pradeep.v
BugFree
Participant
Posts: 82
Joined: Wed Dec 13, 2006 6:02 am

Post by BugFree »

pradeep,

I guess it can be possible through funnel stage.
From transformer/copy get two links.
Propogate the fields "a" and "b" in 1st link.
Propogate the fields "a" and "c" in 2nd link.
Then combine the records through funnel stage. But make sure that you rename one of the field name as "b" or "c" (otherwise funnel stage will not work properly as it expects same metadata from both the links. ).
Ping me if I am wrong...
pradeep_nov18
Participant
Posts: 92
Joined: Wed Mar 05, 2008 4:09 am
Location: chennai
Contact:

Post by pradeep_nov18 »

hi Bugfree,

Ya you are correct,we can achieve that

one doubt

suppose my input

a b c d e
1 10 20 30 40 so on.....

how to achieve
a Computed(col)
1 10
1 20
1 30
1 40
So on...

other than pivot stage.

really thanks for sharing your idea,
pradeep.v
Pagadrai
Participant
Posts: 111
Joined: Fri Dec 31, 2004 1:16 am
Location: Chennai

Post by Pagadrai »

Hi Pradeep,
What I understand is that your number of 'computed columns' in input is not limited.
is this correct ?
pradeep_nov18
Participant
Posts: 92
Joined: Wed Mar 05, 2008 4:09 am
Location: chennai
Contact:

Post by pradeep_nov18 »

Pagadrai wrote:Hi Pradeep,
What I understand is that your number of 'computed columns' in input is not limited.
is this correct ?
Hi Pagadrai,

Exactly :)
pradeep.v
Pagadrai
Participant
Posts: 111
Joined: Fri Dec 31, 2004 1:16 am
Location: Chennai

Post by Pagadrai »

Hi Pradeep,
I can think of a way to do this - though it is not the exact pivoting method.
You dint mention what is the delimiter here.

From your input read the entire record as one column.
say your first record is 1 10 20 30 40.
( i assume delimiter is space)
In the transformer stage, you can get the first value 1 and then replace each of the delimiter ' ' with ' 1,'
so your string looks like 1 1,10 1,20 1,30 1,40
Now, you can replace the space with newline char and write the record 1,10 1,20 1,30 1,40 to output file.

* If you want to further process the resulted records, you have to do it in another job. ( where record delimiter is newline and column delimiter is comma)
pradeep_nov18
Participant
Posts: 92
Joined: Wed Mar 05, 2008 4:09 am
Location: chennai
Contact:

Post by pradeep_nov18 »

Thanks Much Pagadrai

Let me such and get back to you.
pradeep.v
v2kmadhav
Premium Member
Premium Member
Posts: 78
Joined: Fri May 26, 2006 7:31 am
Location: London

Post by v2kmadhav »

Pradeep

You never mentioned about it being a file or perhaps i missed it, if you were expecting to read them as column b, c, d, e ...so on.... with 'a' being your key column

i mean would it be like

a, b, c, null, null, null, null
a, b, c, d, e, null, null
a, b, c, null, null, null, null
a, b, c, d, e, f, g, h

Because i guess you would need to specify a metadata on your source stage??

if not would you be reading them as a, concatenated values b??

that case... you can detemine the number of times a delimiter occurs between these values in column 'b' and feed that into a stage variable. and loop it that number of times using a combination of stage variables based on that against your key column 'a'.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

The technique that Pagadrai mentioned is discussed in this FAQ post by the way.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply