Hello @Sydney ,
Thanks for the question and using MS Q&A platform.
as I understand, you want to flatten two different data structures attributed to similar properties.
I worked closely with Kranthi on your [initial request][1]. It was a challenge. As I recall, we split the data into two streams, one for Student and one for Teacher. Since we split into separate streams, we can then treat each differently. Thus string versus array is not the problem.
The flattening implies you want each name in the array to have its own column. The challenge I see, is that array does not have a fixed length. We could have["Jimmy", "Jon", "Smith", "Wesson", "The third"] or we could have ["Rodrigo","Cortez"].
Having a changing quantity of columns becomes impossible to work with.
However if you wanted to merge the items in an array together into a single string, we solve the issue of name length.
This merge was accomplished in the original ask by:
For name you can use this expression: reduce(name.given, '', #acc + #item + ' ', #result + name.family)
Reduce is a function used to collect all the items in an array and render them into a single result. Usually paired with the map function, and is the origin of the term "map-reduce".
name.given is the array of names. To each element in turn we apply concatenate( everything_so_far , the_next_item)
Then after all items have been done, we do concatenate( the_result, name.family)`
Does this make sense? Is it agreeable? Do you have any suggestions or questions I can clarify or find alternate solution for?