Page 1 of 1

can any one tell example for datastage functions

Posted: Tue Apr 05, 2011 9:27 pm
by kstechno
For example we have Customer table

In customer table
we have a c_id and c_name

c_id c_ name
11 a
11 b
22 c
33 d
44 e
22 f
11 g
33 h
44 i


And my question is
There should be 2 targets and
in Target 1 I need all uniques ids
and in Target 2 I need all duplicates

Can any one send me the full condition we need to write.

I have taken seqfile as a source to read the data
and I have taken sort stage to sort the data
and from there i have taken transformer stage
and I need to write condition there.

Tell me the condition I need to write exactly.

To get the answet in the Target .

Thanks in advance

Posted: Tue Apr 05, 2011 9:57 pm
by chulett
Add a 'key change column' to the Sort stage and then examine the values that come from it. You should easily be able to tell what constraint expression to use for each target.

Posted: Wed Apr 06, 2011 12:33 pm
by kstechno
Yeah this is fine.
Can you tell me the condition to write in transformer stage.
I m not getting correct output when writing condition ( EX if then else condition )
Plz give me the condition with if the else condition .

Thank you

Posted: Wed Apr 06, 2011 1:16 pm
by jwiles
Have you read the documentation for the Sort stage to understand what the keyChange column option provides you and the values it will contain? It's in the Parallel Job Developer Guide.

As a quick exercise, imagine you have a column on your records which uses two distinct values to indicate whether or not a record is the first record of a group of duplicates. In a constraint within a transformer, how would YOU write the logic to select only the first record? In another constraint, how would YOU write the logic to select only the duplicates?

Regards,

Posted: Wed Apr 06, 2011 1:35 pm
by chulett
There's no "if-then-else" needed here. You have two output links and always fully populate both sets of columns with the same data. The key is the constraint so that only one or the other 'fires' for each record and the constraint can make use of the Key Change column.

Posted: Wed Apr 06, 2011 9:45 pm
by kstechno
Thank you very much chulett for your reply.

I got it.

And I need one more answer.

I need the data in the output as below

c_id , c_name

11 a,b,g
22 c,f
33 d,h
44 e,i

Plz reply what condition i can write to get this output.

Thanks in advance

Posted: Thu Apr 07, 2011 12:11 am
by ray.wurlod
Vertical pivot. Search DSXchange for examples.

Posted: Wed Apr 20, 2011 3:41 am
by vishal_rastogi
use the aggregator stage
group it by according to the key column
count the no. of rows by using the count row
now in transformes stage use the constraint .....linkcount = 1 (for uniques)
and linkcount > 1 (for duplicate)