Problem with Aggregator

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
kksr
Participant
Posts: 37
Joined: Fri Dec 30, 2005 5:57 am

Problem with Aggregator

Post by kksr »

Hi All

I am getting a problem while doing the aggregating .

My Input is :
User_ID|Level1|Level2|Level3|Level4
1|A|||
1||B||
1|||C|
1||||D
2|H|||
2||G||
2|||F|
2||||E
My Output Should be :

User_ID|Level1|Level2|Level3|Level4
1|A|B|C|D
2|H|G|F|E

I am using Aggregator , but the actual output is :

User_ID|Level1|Level2|Level3|Level4
1|0|0|0|0
2|0|0|0|0

I have tried with SUM and MAX function aggregator , I am getting the above output .and getting following error .

Implicit conversion from source type "string[max=2]" to result type "dfloat": Converting string to number.

The same logic was working fine in Server by Using FIRST or LAST fucntion in aggregator stage .

Pls suggest how to use First(server ) function in PX to get the expected output.

Thanks In Advance
Kiran
KKSR
dhanashreepanse
Participant
Posts: 25
Joined: Fri Jan 11, 2008 12:49 am
Location: Pune, India

Post by dhanashreepanse »

1. What are you setting the Aggregation Type as ?

2. Which column are you setting as the "Column for Calculation?

3. What are the data types for : User_ID|Level1|Level2|Level3|Level4 ?
kksr
Participant
Posts: 37
Joined: Fri Dec 30, 2005 5:57 am

Post by kksr »

I am using the Level1 ,Level2 ,Level3 & Level4 for calculation purpose.And thye data type is Char .

Thanks
Kiran
KKSR
dhanashreepanse
Participant
Posts: 25
Joined: Fri Jan 11, 2008 12:49 am
Location: Pune, India

Post by dhanashreepanse »

I think that the Aggregator may not work in this case because of the data type. DS Gurus,correct me if I am wrong.

You can try this approach:
Pass the input file to a transformer and get the output as
1|A
1|B
1|C
1|D
by applying some logic in the transformer.

Then pass it to a Pivot stage to get it in a single row.
vasa_dxx
Participant
Posts: 39
Joined: Sun Sep 28, 2008 2:59 am
Contact:

Post by vasa_dxx »

Aggregator stage is not feasible for Characters but only for Numbers.
Two wrongs don't make a right. But three lefts do.
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

The aggregator defaults to a data type of dfloat. If you want the aggregator to maintain the data type of the input column, you must specify that by setting the "Preserve Type" property to True.

Mike
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

You obviously can't do a SUM on character data, but a MAX will work just fine.

Mike
Post Reply