logic required

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

hargun
Participant
Posts: 188
Joined: Mon May 16, 2011 7:41 pm
Location: United States

logic required

Post by hargun »

hi,

i have three columns in seq file as follows but i need the out put int he following way .Two extra columns required as per requirement GROUP and FAMILY

Code: Select all

Name            Phone_desc         Phone_number          GROUP    FAMILY
ABC                work            123-456-789            1         Y
XYZ                CELL            857-657-798            2         N
GHI                WORK            123-456-789            1         Y
IF NAME : ABC AND GHI having same phone number then it should come under group 1 and FAMILY is also "Y" for both of them.

Similarly if XYZ is having different cell the group should be 2 and family is "N"

In nutshell the names with same phone number comer under same group 1 and Family is "y" for those and for different phone number group is like 1,2,3 etc follows by Family as "N".

i appreciate the response.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Cleaned up your example.

:idea: People, please remember that you MUST use code tages if you want to preserve white-space in your super duper examples with (for example) columns of data. Otherwise the forum software removes all of your 'extra' spaces. It has been doing this for years, learn to love the Preview button to make sure your example still survives and makes sense when others see it. Please.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Hargun, you know the drill by now... what have you tried? What problems are you having? Your requirement seems pretty straight-forward so far.

Do you need to preserve the original file order? That's the only thing that might make this a little tricky.
-craig

"You can never have too many knives" -- Logan Nine Fingers
hargun
Participant
Posts: 188
Joined: Mon May 16, 2011 7:41 pm
Location: United States

Post by hargun »

chulett wrote:Cleaned up your example.
i apologise will take care
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

No worries, that message was for everyone - not picking on you specifically. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
hargun
Participant
Posts: 188
Joined: Mon May 16, 2011 7:41 pm
Location: United States

Post by hargun »

i tried by adding new column Group and family in transformer and then tried by using the aggregator stage after transformer but unable to get the result.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

There's no aggregation needed here.

If you don't need to preserve the input order, what about using a Sort stage and having it add a group change key? You could then do what you need in stage variables after that.
-craig

"You can never have too many knives" -- Logan Nine Fingers
hargun
Participant
Posts: 188
Joined: Mon May 16, 2011 7:41 pm
Location: United States

Post by hargun »

Can you help me what i have to define in stage variables .I appreciate.
ds@tcs
Participant
Posts: 24
Joined: Thu Mar 17, 2011 6:26 am
Location: chennai
Contact:

Post by ds@tcs »

Your job esign would be:
seqfile-> sort1-> sort2-> tsfr-> target

logic would be:
Sort1- Sort on ph no with Key change col=True--Asc

Sort2- Sort on Ke change col, ph no-asc

Tsfr- Create stgv1 stggroup, Stgv2 Stgfamily, Stgv3 stgprev(Default=1)
stggroup= If keyChange =1 And Stgprev =1 Then 2 Else 1
Stgfamily= If Stggrp =1 Then 'Y' Else 'N'
stgprev= DSLink32.keyChange

map stggroup with group, stgfamily with Family.

-
Sankar
Regards
Sankar
stuartjvnorton
Participant
Posts: 527
Joined: Thu Apr 19, 2007 1:25 am
Location: Melbourne

Post by stuartjvnorton »

I hate "requirements" based on trivial examples.
What happens if you have a 4th record:

Code: Select all

Name            Phone_desc         Phone_number          GROUP    FAMILY
ABC                work            123-456-789            1         Y
XYZ                CELL            857-657-798            2         N
GHI                WORK            123-456-789            1         Y

JKL                CELL            857-657-798            ?         ?
Rakesh311
Participant
Posts: 36
Joined: Wed Aug 04, 2010 10:53 pm
Location: Banglore
Contact:

Post by Rakesh311 »

Sort by phone number and Name , then for each of that group u can have specific GROUP and FAMILY.

Try it out , you can do it easily :)
rAKESH
ds@tcs
Participant
Posts: 24
Joined: Thu Mar 17, 2011 6:26 am
Location: chennai
Contact:

Post by ds@tcs »

stuartjvnorton wrote:I hate "requirements" based on trivial examples.
What happens if you have a 4th record
It will work with N no of rows. Try it out.
Regards
Sankar
chandra.shekhar@tcs.com
Premium Member
Premium Member
Posts: 353
Joined: Mon Jan 17, 2011 5:03 am
Location: Mumbai, India

Post by chandra.shekhar@tcs.com »

@Sankar,
I dont think that will work, for the 4th record GROUP should have "3".
In your logic the counter thing is missing, so you have to use one more variable for incrementing the counter.
Thanx and Regards,
ETL User
ds@tcs
Participant
Posts: 24
Joined: Thu Mar 17, 2011 6:26 am
Location: chennai
Contact:

Post by ds@tcs »

You are right. I thought the requiremnt will be with two groups. If group no is increasing then we need a count variable.
Regards
Sankar
hargun
Participant
Posts: 188
Joined: Mon May 16, 2011 7:41 pm
Location: United States

Post by hargun »

ds@tcs wrote:Your job esign would be:
seqfile-> sort1-> sort2-> tsfr-> target

logic would be:
Sort1- Sort on ph no with Key change col=True--Asc

Sort2- Sort on Ke change col, ph no-asc

Tsfr- Create stgv1 stggroup, Stgv2 Stgfamily, Stgv3 stgprev(Default=1)
stggroup= If keyChange =1 And Stgprev =1 Then 2 Else 1
Stgfamily= If Stggrp =1 Then 'Y' Else 'N'
stgprev= DSLink32.keyChange

map stggroup with group, stgfamily with Family.

-
Sankar


hi,

i tried by using the above logic but its not giving the result expected ,its give group 1 and Family Y for each phone number ,group is not increment for each different number.
Post Reply