#1 2012-04-25 19:25:50

DARWI
New member
Registered: 2012-03-22
Posts: 8

tmap : join between

Hi,

I would like to join two files using simple condition "fileA.date between (fileB.datefrom and fileB.dateto)". very simple with sql but how to do that with Talend ?

Example :

File A : contain all the day for a year
dateofday    | monthofday |
01-01-2012 | 01
02-01-2012 | 01
03-01/2012 |01
...

File B : contain official holliday period
begindateholliday | enddateholliday | label_hollidays
26-12-2011         | 08-01/2012      |  chrismas

What I want to have in output :

dateofday    | monthofday | label_hollidays
01-01-2012 | 01               | christmas
02-01-2012 | 01               | christmas
03-01-2012 | 01               | christmas
...

Can I do that with tmap ? If yes, what is the synthax and link to define between my two source files ?

Regards.

Offline

#2 2012-04-25 19:55:43

phobucket
Member
Company: Knoetry
Registered: 2010-07-27
Posts: 146
Website

Re: tmap : join between

Hi DARWI, you put the join conditions in the filter criteria on the lookup table.
http://www.talendforge.org/forum/viewtopic.php?id=10386

Since you are comparing dates, you would either convert the dates to numeric values which could be compared with arithmetic operators, or use something like this
(DWSTalendDate.compareDate(row1.dateOfDay ,row2.begindateholliday ,"yyyy-MM-dd")>= 0)
   &&
(DWSTalendDate.compareDate(row1.dateOfDay ,row2.enddateholliday ,"yyyy-MM-dd")< 0)

Depending on you data, you may want to add a tUniqRow after the tMap.

Thanks,
Ben

Offline

#3 2012-04-27 19:14:31

DARWI
New member
Registered: 2012-03-22
Posts: 8

Re: tmap : join between

Excellent !! That works perfectly.

Thank you a lot.

Offline

Board footer

Powered by FluxBB