Transformer

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
ag_ram
Premium Member
Premium Member
Posts: 524
Joined: Wed Feb 28, 2007 3:51 am

Transformer

Post by ag_ram »

Hi,

I have a requirement as follows.
there are 3 columns User,role, and code
sample records

U1,R1,D
U1,R1,U
U2,R1,D
U2,R2,U

and i need to select only

U2,R1,D
U2,R2,U

meaning i should not select if same user/role combination has 2 codes, in the above ex U1/R1 combination has two codes D and U and so need to reject both the rows

can i do this with the help of only a transformer stage and if so pls let me know.

Note : Records will be sorted on User/role keys.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Sure, stage variables doing normal 'group change detection' in a Transformer can handle this easily since the data is sorted properly. Keep track of the current and previous combination of User and Role, then only pass a record on the first time you see each particular combination.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ag_ram
Premium Member
Premium Member
Posts: 524
Joined: Wed Feb 28, 2007 3:51 am

Post by ag_ram »

thanks for ur reply, but my requirement is like i should not pass a record on the first time I see each particular combination, if combination repeats i should reject that combination entirely, whichever combination comes only one time i shud select that.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

D'oh... misread things. Jury will disregard all statements made by the witness.
-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 »

Obviously, you can't do this in a Transformer - at least not without some preprocessing or as the second of two passes through the data. First pass would be to determine which records should be 'rejected' and then a second to do the dirty deed.

Unless there's some magical way in PX to do this all at once? [shrug]
-craig

"You can never have too many knives" -- Logan Nine Fingers
Minhajuddin
Participant
Posts: 467
Joined: Tue Mar 20, 2007 6:36 am
Location: Chennai
Contact:

Post by Minhajuddin »

I don't see how this can be done using *just* a Transformer.

I had a similar problem and had used two sort stages with a transformer to remove these duplicates. Here is the post where Josh helped me out viewtopic.php?t=110447&highlight=

Hope that helps
Minhajuddin

<a href="http://feeds.feedburner.com/~r/MyExperi ... ~6/2"><img src="http://feeds.feedburner.com/MyExperienc ... lrow.3.gif" alt="My experiences with this DLROW" border="0"></a>
ag_ram
Premium Member
Premium Member
Posts: 524
Joined: Wed Feb 28, 2007 3:51 am

Post by ag_ram »

Thanks for ur reply guys, it works fine.
sreenidr
Participant
Posts: 4
Joined: Tue Dec 04, 2007 9:22 am

Post by sreenidr »

We can do this using a single transformer, however it requires one dummy record at the end. This is because we don't know until next record is processed if the previous one qualifies to be outputted..

In the test map I developed, I added the dummy record using a row generator and funnelling(sequencially) along with input before hitting the transformer stage...

Here is what I did in the transformer..

--------------------------------------------------
Stage Variables:

sCount = sPrvCount
if ( ( sUser=x.User) and (sRole=x.Role) ) then sCount+1 else 1 = sCount

sUser=sPrvUser
sRole=sPrvRole
sValue=sPrvValue

lnk.User = sUser
lnk.Role = sRole
lnk.Value = sValue

-------------------------------------------------------------
Mapping

Link Condition = ( ( sPrvUser<>Lnk.User) or (sPrvRole<>Lnk.Role) ) and sPrvCount=1

sPrvUser = User
sPrvRole = Role
sPrvValue=Value

----------------------------------------------------------


Idea is simple as with other postings tp remove duplicates. However we need one extra 'count' stage variable to hold count of previous set of records. If this count=1, means the previous set of record have only one record so it will be allowed to pass the transfomer link.

The approach uses an additional row generator and a sequencial funnel, both are lite weight. However, if a dummy record say ZZ,ZZ,Z can be added part of file, we can then achive everything within the Transfomer stage..
--------------------------------------------------
Srini

When the Going Gets Tough, the Tough Get Going!
sreenidr
Participant
Posts: 4
Joined: Tue Dec 04, 2007 9:22 am

Post by sreenidr »

--Duplicate posting deleted---
Last edited by sreenidr on Wed Dec 05, 2007 9:25 am, edited 2 times in total.
sreenidr
Participant
Posts: 4
Joined: Tue Dec 04, 2007 9:22 am

Post by sreenidr »

deleted
Last edited by sreenidr on Wed Dec 05, 2007 9:25 am, edited 1 time in total.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

:idea: Rather than posting again to explain why it happened, next time just edit the duplicate post and then select the 'Delete' option. They can be deleted as long as there is no reply posted.
-craig

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