joining datasets

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
kcshankar
Charter Member
Charter Member
Posts: 91
Joined: Mon Jan 10, 2005 2:06 am

joining datasets

Post by kcshankar »

Hi,

I have two datasets with same no.of columns and rows.
I want to join these datasets and the output dataset should have same num of rows.
Is there any method apart from lookup.

Table 1
A B
1 2
1 4

Table 2
A C
1 3
1 5

and I want the output like

A B C
1 2 3
1 4 5


Thanks in advance
kcs
Prashantoncyber
Participant
Posts: 108
Joined: Wed Jul 28, 2004 7:15 am

Post by Prashantoncyber »

hi,

you can append a dummy colum in each table using transferformer to create data like this

Table 1

A B Dummy Column
1 2 X
1 4 X


Table 2

A C Dummy Column
1 2 X
1 4 X

now use join Stage subsequently to get the desired result using Dummy
column as key.

Thanks
Prashant
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
look at the join,merge stages
I think you will find that a lookup is probably the fastest way.

IHTH,
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
kcshankar
Charter Member
Charter Member
Posts: 91
Joined: Mon Jan 10, 2005 2:06 am

Post by kcshankar »

Hi Prashant & Roy,
thanks for your reply.

Prashant, Column A is a dummy column in my job and I tried using that but iam getting duplicate rows.
I want output dataset of same num of rows as of source(ie both my source file have 1000 rows, i want the resulting file of 1000 rows).



Thanks in advance

kcs
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

When you write in a dataset, the rows will not be organized as it was in the source. Hence you may lose the order.

But if this is ok, you can use stage variables to write sequential numbers and then join on that.
kcshankar
Charter Member
Charter Member
Posts: 91
Joined: Mon Jan 10, 2005 2:06 am

Post by kcshankar »

Hi Sai,
Thanks for your reply. :D

I got the solution.

I used column generator to create dummy column with sequence,then I use Join stage to get the required output.

Table 1
A B
aa 2
bb 4

Table 2
A C
aa 3
bb 5

Output Table
A B C
aa 2 3
bb 4 5



Thanks Sai
kcs
Post Reply