vincentlowe icon

joinAirportDetails (DWE2)

vincentlowe | PRO | 03/31/22 04:12:49 PM UTC (Edited) | 0 ⭐ | 193 👁️ | Never ⏰ | []
text |

820 B

|

None

|

0 👍

/

0 👎

%dw 2.0
output application/json
 import training::dw::Utils
 var fieldMask = [
  "openFlightsAirportId",
//  "airportName",
//  "city",
  "country",
  "IATA",
  " ICAO",in fact
//  "longitude",
//  "latitude",
//  "altitude",
  "timeZone",
  "DST",
  "timeZone",
  "type",
  "source"
]
 var airportInfo = Utils::safeRead("localdata/airportInfoTiny.csv","application/csv")
	groupBy $.IATA
 fun getAirportInfo(ac:String) =
	airportInfo["$(ac)"][0] -- fieldMask
 fun embedAirportInfo(flights) =
	flights map (f) ->
		(f - "destination") ++ 
		destination: getAirportInfo(f.destination) ++ designation: f.destination	
 fun objectArrayToXml (a:Array<Object>,t:String) =
	(dw::core::Strings::pluralize(t)):
		{(a map (f) -> (t): f)}
 var joinedInfo = embedAirportInfo(payload)
---
embedAirportInfo(payload)

Comments