I am having below transformation which is taking significant time, and I tried many ways to optimize this.
Can anyone guide me in right direction please.
%dw 2.0
output application/json
fun getColName(mname) = {
name: vars.columnMap filter($.mname == mname)
}
---
vars.sqlResult map (
$ mapObject(v, k) -> {
(((getColName(k as String).name[0]).saneName): (trim(v as String)))
if(k as String != "A" and k as String != "B" and k as String != "C" and k as String != "D"),
(((getColName(k as String).name[0]).saneName): (trim(v as Number {format: "############.##"} as String {format: "###########0.00"})))
if(k as String == "A" or k as String == "B" or k as String == "C" or k as String == "D")
}
)
vars.sqlResult is java object returned from SQL query, which has 25 columns (roperties), just 100 count
vars.columnMap has below structure, with count just around 100
[
{
“mname”: “name”,
“saneName”: “saneName”
}
]