Forum Discussion

XanderVR's avatar
XanderVR
New Contributor
2 months ago
Solved

Generate expression file from database query

For some data transformations I would like to use an expression file that is generated each night, instead of querying a SQL database everytime the pipeline is started. I already have data available...
  • SpiroTaleski's avatar
    2 months ago

    XanderVR​ Achieving the desired output (without the getValue function) can be done using the reduce function. 

    First you need to group the records by $code, using Group By Fields snap. After that following expression can be used: 

    {[$groupBy.code]:$group.reduce((acc, curr) => acc.extend({[curr.source]: curr.target}), {})}

    BR,

    Spiro