Pivot & Filter - Alternative option

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
vijayrc
Participant
Posts: 197
Joined: Sun Apr 02, 2006 10:31 am
Location: NJ

Pivot & Filter - Alternative option

Post by vijayrc »

Friends,
I have a scenario like this...The input to Transformer is a record which has 4 occurences of a particular set of fields..
e.g, Input
Common Field1;Common Field2;Common Filed3; FieldA;FieldB;FieldA_1;FieldB_1;FieldA_2;FieldB_2;FieldA_3;FieldB_3
Output:
Common Field1;Common Field2;Common Filed3; FieldA;FieldB
Common Field1;Common Field2;Common Filed3; FieldA-1;FieldB-1
Common Field1;Common Field2;Common Filed3; FieldA-2;FieldB-2
Common Field1;Common Field2;Common Filed3; FieldA-3;FieldB-3

Transformer==>Pivot==>Filter [to filter any of the occurence when FieldA_* is zero]
Is there an alternative to get rid of this filter stage and yet get the task accomplished?
Thanks
Vijay
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Probably another transformer after the pivot stage to constraint the output maybe :roll:
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Don't pass such rows through the first Transformer. Add the four checks to the output link constraint expression, conjoined with AND operators.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Constraint and then pivot. This way you dont need an extra stage. Why didnt I think of that. Probably I was too tired.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Too rushed, grasshopper.

Take the time to smell the flowers.

Meditate for a while. Ponder the questions.

:idea:
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Your right, I need to slow down. Probably still a kid in datastage :roll:
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
vijayrc
Participant
Posts: 197
Joined: Sun Apr 02, 2006 10:31 am
Location: NJ

Post by vijayrc »

ray.wurlod wrote:Don't pass such rows through the first Transformer. Add the four checks to the output link constraint expression, conjoined with AND operators. ...
Ray
I'm not clear on this. Did you mean to have the four checks on the output constraint of the pivot ?!?!?! or do you mean to have an output link constraint expression on the first transformer to the pivot to be [if FieldA >0 AND FieldA_2 >0 AND FieldA_3>0 AND FieldA_4 > 0]
Anyhow I need the first transformer to do other stuffs besides passing some rows to the pivot.
Last edited by vijayrc on Thu Feb 01, 2007 7:06 pm, edited 1 time in total.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

No, Constraint it in the first transformer itself. You cannot do it in the pivot stage.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Yes, I meant in the first Transformer stage. And it's perfectly OK that this stage does "other stuff". All my suggestion adds is an additional condition on the output constraint expression - it does not affect anything else you are doing with this Transformer stage.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
vijayrc
Participant
Posts: 197
Joined: Sun Apr 02, 2006 10:31 am
Location: NJ

Post by vijayrc »

ray.wurlod wrote:Yes, I meant in the first Transformer stage. And it's perfectly OK that this stage does "other stuff". All my suggestion adds is an additional condition on the output constraint expression - it does ...
Thanks..I'm not getting a way to work out..If you can get me the expression with my above example, may be that would help.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

FieldA <> 0 And FieldA_1 <> 0 And FieldA_2 <> 0 And FieldA_3 <> 0
And any other constraint that you may already have.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
vijayrc
Participant
Posts: 197
Joined: Sun Apr 02, 2006 10:31 am
Location: NJ

Post by vijayrc »

ray.wurlod wrote:

Code: Select all

FieldA <> 0 And FieldA_1 <> 0 And FieldA_2 <> 0 And FieldA_3 <> 0
And any other constraint that you may already have. ...
Ray, by doing this, Only if all the four fields [FieldA,FieldA_2,Field_3,Field_4 are non-zeros] then the constraint gets satisfield.
My requirement is if FieldA is 0, FieldA,FieldB shouldn't be written out,
If FieldA_2 > 0, FieldA_2,FieldB_2 should be writtenout and
If FieldA_3 > 0, FieldA_3,FieldB_3 should be writtenout and
If FieldA_3 = 0, FieldA_4,FieldB_4 shouldn't be writtenout
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You did not make that clear till now.
Your only solution will require four separate output links, separately constrained, since they will have different metadata.
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