Forum Discussion
Amazing @viktor_n. I made a little change and your trick worked perfectly. You deserve an award 🙂
I will be using it in my original pipeline to see the same result. Would mind clarifying the “findIndex()” used here?
I transformed the column mapping accordingly. Not an issue.
findIndex() function is used for searching the index of a particular element in Array. If match is not found, -1 is returned.
Syntax: { Array }.findIndex(((element, index, array) => { condition })
Accepts a callback function that returns 3 parameters.
- First parameter is the value of each element
- Second is the index
- Third is the original array.
The returned index is the index of the first element that returns true.
$Mapping.findIndex(el => el.src_col_name == key)
Here inside the expression I check if the ‘Mapping’ array has ‘src_col_name’ with a value same as the field from the root($), and if it finds a match it will return the index of that particular element, otherwise it will be -1.
Hope this will help you