Problem in Join stage

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
sanygup
Participant
Posts: 34
Joined: Thu Sep 20, 2012 10:19 am
Location: newdelhi

Problem in Join stage

Post by sanygup »

Hi,

I am not able to use the join stage properly and getting wrong result.

I have two tables : Table A and Table B

Table A has following columns:
Country varchar (50), Country_code varchar(10)

Table B has :
Country_code varchar(10), Car_name varchar(10)

Table A records:
Country_code Country
------------------------------------
IN Pakistan

Table B records:
Country_code Car_name
-------------------------------------
IN Verna
IN BMW
PK Audi

When I try to do inner join output returns as 0 records (key column is country_code).
But when I use integer in place of varchar as data type of contry code, job works fine.


Please provide the solution that where I am committing the mistake.

Thanks,
Aspirant
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Often this type of error is because one or another of the Country_Code columns has spaces in it. You can test this by doing a TRIM() of both columns in a stage before the join.
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Re: Problem in Join stage

Post by priyadarshikunal »

sanygup wrote: When I try to do inner join output returns as 0 records (key column is country_code).
But when I use integer in place of varchar as data type of contry code, job works fine.
This line just caught my eyes, If you change the datatype to integer and all the columns you mentioned is varchar, yes, you will be able to get the match as everything becomes zero but it will cause cartesian product and will not output correct result. Are you getting correct result even if the job is working fine.

Make sure you get the partitioning correct and check what Arnd suggested.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Somewhat off topic (more a data quality issue), why does IN decode to "Pakistan"?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sanygup
Participant
Posts: 34
Joined: Thu Sep 20, 2012 10:19 am
Location: newdelhi

Post by sanygup »

Thanks you all (kunal,ray and arndw) for replying the topic, I got the issue resolved by applying link sort on input link of Join stage over 'country_code' which is a key field of Join stage. Now the result is as expected.
Aspirant
Post Reply