JSON or Array in a tmap

Six Stars

JSON or Array in a tmap

Hi

 

I have a input file that contains a start time for a booking and a duration (xx minutes where xx is numeric).  I want to work out the end time for the booking based on these 2 parameters which is easy by using addDate.

 

However, the duration sometimes contains -1 which signifies a the booking runs until closing time for a restaurant. 

I have a list of closing times for the venue by day of the week which are sometimes different and so instead of the addDate, where duration is -1 I then want to pull in the closing time and join that to the booking start time before converting to a date.  Again quite easy...


TalendDate.parseDate("yyyy-MM-dd HH:mm:ss",(StringHandling.LEFT(row4.booking_date,10) + " " + Var.closing_time)) 

 

However, I'd ideally like to be able to read lookup table containing a list of all closing times held in one column either as an array or a JSON string, then depending on the day of the week which I can work out, set the correct closing time for the venue.

 

I'm currently doing a straight lookup to a table containing the closing times but have set one per venue.  Clearly a challenge but hopefully someone has a solution....

 

Thanks

Dave

Eleven Stars

Re: JSON or Array in a tmap

One of the way , assuming your lookup array is like
Mon,17:30
Tue,18:30
.
.
Sun 23:00

Input — tjavarow( add another col with day of week of reservation datelike mon,tue ..it can be done by format date function EEE expression) — tmap (with lookup of closing time, inner join) — output ( if duration is -1 , read add lookup closing time otherwise duration to reservation date )

Hope this would be helpfull)
Regards
Abhishek KUMAR

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog