tMap one to many mapping

One Star sid
One Star

tMap one to many mapping

Hi ,
Can anybody tell me what is the problem with the below mapping.There is a one to many mapping between these two tables ie for a FacilityId I can have more than one Ratings,but by this mapping Iam getting only one Rating (ratingtypecode,ratingvalue) in my output
One Star sid
One Star

Re: tMap one to many mapping

Anybody there ???????
One Star sid
One Star

Re: tMap one to many mapping

sorry did not notice the o/p file properly .Iam getting the o/p in the below format .But i want the o/p as a single record (Expected o/p is at the bottom.How can i get this format??
Cusip 04C9
MaturityDate 20100630
descript TL A2
payfreq 97208125
issamt 2.25
OUTAMT 0
MTerm Ba3
ticker 97208125
Cusip 04C9
MaturityDate 20100630
descript TL A2
payfreq 97208125
issamt 2.25
OUTAMT 0
STerm BB-
ticker 97208125
Cusip 04C9
MaturityDate 20100630
descript TL A2
payfreq 97208125
issamt 2.25
OUTAMT 0
CiRating 5
ticker 97208125
Expected O/p ::::::::::::::::::::::::::::::::::
Cusip 04C9
MaturityDate 20100630
descript TL A2
payfreq 97208125
issamt 2.25
OUTAMT 0
MTerm Ba3
CiRating 5
STerm BB-
ticker 97208125
Community Manager

Re: tMap one to many mapping

Hi
Your request looks like this 1995.

Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star sid
One Star

Re: tMap one to many mapping

Hi Shong
That was my request itself Smiley Happy .. But that was only for a single table..There is a join between two tables here (a one two many join) ..
Please see my tMap mapping
Thanks
Abrar
One Star

Re: tMap one to many mapping

Hi shong
Is this mapping possible?
Thanks
Abrar
Employee

Re: tMap one to many mapping

I think you could process your data in two steps :
1)
You extract and put in 3 diffrents files your data and ONE of the fields MTerm, CiRating and CiRating.
Take one fileInput (with N lines in the file), one tMap and three fileOutputs, one output for each field MTerm, CiRating and CiRating.
2)
Then, you read the first file as Main row, and the others as lookups. So, you will be able to merge your commons data and your specific fields.
Take the three files in input of the tMap and connect one output which will contain N/3 lines at end of process.
Don't forget to use a ThenRun connection to separate these two processings.
Maybe someone will have an other idea ?
One Star

Re: tMap one to many mapping

I agree with amaumont - you will need to pre-process the input file into 3 temporary outputs first. After a ThenRun you'll need to process the 3 outputs and join them on the key column(s). All of this assumes that you only need the columns defined in your output table.
If the size of your data isn't too large, then I'd suggest using the "hidden" components tArray and tArrayIn (please search the forum for information on these). You can then do the whole job "in memory".
Also please remember to be polite in the forum. Expecting an answer within 90 minutes, cross posting and bumping is not considered "forum etiquette".
c0utta
One Star sid
One Star

Re: tMap one to many mapping

Thanks cOutta/amaumont for your suggestion.
Apologies for getting desperate to get the answer (had to submit POC to my manager about Talend)
I tried to solve this according to the below way
1.I used tFilterRow to filter rows ( I used only two rating types) into two different files.
2.Then used a tMap to map one of these files with the main query result
3.Thought of mapping the second file with the output of the tMap ,but as column names are same ,was not able to map the second file with the tMap o/p.Pls see the attached screen shot
4.Is there a way to map it this ways ??
BTW I think I can use tArray as my data size is very big
Thanks
Abrar
Employee

Re: tMap one to many mapping

Use ThenRun connection to process your job in two steps.
One Star

Re: tMap one to many mapping

If the size of your data isn't too large, then I'd suggest using the "hidden" components tArray and tArrayIn (please search the forum for information on these). You can then do the whole job "in memory".

I searched but did not find an detailed example for the tArrayIn usage with Java.
But what I found was http://talendforge.org/forum/viewtopic.php?pid=6057#p6057 with an error message I?m able to reproduce.
Any suggestion on the correct usage of tArrayIn (for Java)?
One Star

Re: tMap one to many mapping

Hi Vaiko,
I create Perl jobs, so I can't comment on the Java implementation. Nonetheless, I created the equivalent job in Java that demonstrates the basic use of tArray and tArrayIn and it fails with
Exception in component tArrayIn_1
java.lang.ClassCastException: p2069.p1602.p1602$row1Struct cannot be cast to p2069.p1602.p1602$ThenRunStructarray_tArray_1
at p2069.p1602.p1602.tArrayIn_1Process(p1602.java:155)
at p2069.p1602.p1602.tRowGenerator_1Process(p1602.java:361)
at p2069.p1602.p1602.runJob(p1602.java:447)
at p2069.p1602.p1602.main(p1602.java:383)

I would create an entry in the bug tracker if you want this resolved. I reported the same (or similar) bug for Perl with http://talendforge.org/bugs/view.php?id=2431
Cheers,
c0utta
One Star sid
One Star

Re: tMap one to many mapping

Hi amaumont
Use ThenRun connection to process your job in two steps.

Can you please explain me in detail as Iam new to this tool..Is the mapping which i did correct ???,if yes where should i use ThenRun.If possible pls send me a screen shot
Thanks
Syed Abrar
One Star sid
One Star

Re: tMap one to many mapping

Even tried this way ..still not able to map
Employee

Re: tMap one to many mapping

In the joined schreenshot, you can see a job where intermediate data (DATES_MATCHES and ALL_BEFORE_DATES) is written in a first step and read in a second step (up to bottom) to find final results (tLogRow).