how to use join stage for joinig more than two tables

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
agrawal.sunil
Participant
Posts: 5
Joined: Mon Jun 29, 2009 4:47 am
Location: Bangalore

how to use join stage for joinig more than two tables

Post by agrawal.sunil »

Hi,
I want to use Join Stage for joining three tables. Suppose I have 3 tables names respectively: A, B and C. Table A and B are to be joined on key column 'K1' and table B and C are joined on key column 'K2'. I have specified table B as intermediate, table A as left and table C as right, in the link ordering setting. Please help me to specify as to which key column of K1 and K2 is meant for which pair of tables that I want to join.
Pair1-> Left - Intermediate
Pair2-> Right - Intermediate

Kindly help me in this matter.
Thanks,
Sunil
aaryabhatta
Premium Member
Premium Member
Posts: 20
Joined: Mon Dec 19, 2005 10:00 pm
Location: UK

Post by aaryabhatta »

I guess its best to use the User-defined SQL query in database stage, in which case database indexes will be used and will be faster compared to join stage.
Klaus Schaefer
Participant
Posts: 94
Joined: Wed May 08, 2002 8:44 am
Location: Germany
Contact:

Re: how to use join stage for joinig more than two tables

Post by Klaus Schaefer »

In one join stage you can join multiple links on the same keys only. In your case you have to use 2 joins: join A and B on K1 and then repartion, sort and join B and C on K2.

Klaus
dsuser_cai
Premium Member
Premium Member
Posts: 151
Joined: Fri Feb 13, 2009 4:19 pm

Post by dsuser_cai »

Do a row count before going for a join stage. If the row count is very less use SQL query to join the tables, ot use a look up instead, go for join only if its necessary(very huge data/less space)
Thanks
Karthick
agrawal.sunil
Participant
Posts: 5
Joined: Mon Jun 29, 2009 4:47 am
Location: Bangalore

Re: how to use join stage for joinig more than two tables

Post by agrawal.sunil »

Klaus Schaefer wrote:In one join stage you can join multiple links on the same keys only. In your case you have to use 2 joins: join A and B on K1 and then repartion, sort and join B and C on K2.

Klaus
Thanks Klaus :)
-
Thanks & Regards
Sunil Agrawal
anandsiva
Participant
Posts: 41
Joined: Wed May 21, 2008 7:58 pm
Location: Sydney

Post by anandsiva »

Do use SQL which is much more faster for these kind of joins. We are using these kind of joins and we generally prefer SQLs for these operations.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The short answer to the original question is that the Join stage supports more than two input links if required. They are called "Left", "Intermediate" and "Right" in the Input Link Ordering dialog. I believe that joins are performed pairwise, beginning from the left.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Marley777
Premium Member
Premium Member
Posts: 316
Joined: Tue Jan 27, 2004 3:26 pm

Post by Marley777 »

What is an intermediate file, what does it give you?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

More than two inputs.

In SQL it would look something like
SELECT columns FROM tableA,tableB,tableC
WHERE tableA.key = tableB.key AND tableA.key = tableC.key

tableB is the intemediate here.
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