Lookup

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
IBMDS
Participant
Posts: 20
Joined: Thu Nov 09, 2006 1:58 pm

Lookup

Post by IBMDS »

I have a scenario like this

In source i have multiple values in lookup table i have distinct records

Source table

column1

xyz all a
xyz-all
xyz - all
rxz
rxzab - 1
rxzab - all

In lookup table

Lcolumn1 Lcolumn2 Lcolumn3

xyz 2 1
rxz 3 2

i need to get the ouput like this

Column1 Lcolumn2 Lcolumn3

xyz all a 2 1
xyz-all 2 1
xyz - all 2 1
rxz 3 2
rxzab - 1 3 2
rxzab - all 3 2


Please suggest me regarding this,

Thanks in Advance
IBMDS
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It's an inner join, isn't it? Therefore a Join stage would seem apposite. Upstream of that stage, generate the lookup value (a substring of the source key). If the reference data set is sufficiently small, a Lookup stage may be more performant. Return all columns except the key from the right/reference input.
Last edited by ray.wurlod on Mon Nov 20, 2006 6:01 pm, edited 1 time in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
thebird
Participant
Posts: 254
Joined: Thu Jan 06, 2005 12:11 am
Location: India
Contact:

Post by thebird »

Hi,

Assuming that every data in the first column of your reference table is going to be having a length of 3, you can accomplsh this using a Lookup stage or a Join stage (depending on the reference data volume).

If using a lookup stage, then create an additional column from your source link containing the first 3 characters (you can use the substring function in the Modify stage for this) and then this new column can be made as the Lookup/Join key with the reference link. To your output you can pass the the original column1 and columns 2 and 3 from the reference.

I believe this should get you what you are loking for.

Regards

The Bird
thebird
Participant
Posts: 254
Joined: Thu Jan 06, 2005 12:11 am
Location: India
Contact:

Post by thebird »

thebird wrote: If using a lookup stage, then create an additional column from your source link containing the first 3 characters (you can use the substring function in the Modify stage for this) and then this new column can be made as the Lookup/Join key with the reference link. To your output you can pass the the original column1 and columns 2 and 3 from the reference.
You can use the same approach when using the join stage too.

The Bird
samba
Premium Member
Premium Member
Posts: 62
Joined: Wed Dec 07, 2005 11:44 am

Post by samba »

Thanks Ray and the bird

Its not inner join and length is not fixed in source table and lookup table.
samba
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It IS inner join

Code: Select all

WHERE SUBSTRING(left.key,1,3) = right.key
You just need to do the substring piece in an upstream 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.
Post Reply