I think I may have to eat my words on this. @Anonymous
After much fiddling, I found 80% success. Partial success because I needed to define part of the schema. In order for Flatten to work, the thing you unroll by must be defined in the schema. In order for results
to be recognized as a complex object, it must have at least one property. This means if you have one property field common to all the files like "ID", we can use this in the schema, and leverage schema drift to handle everything else.
If you want to understand what I mean, import the schema, then go to the script and delete some of the members under 'results'. Then go enable 'allow schema drift' and maybe 'detect drifted types' and check the source preview.
To catch all the unknown columns while Flattening, I had to use a rule-based deep traversal. I set the match condition to true()
so everything would be caught, and preserved the names by using $$
for Name as
. With enabling deep traversal I set Hierarchy level
to results
In the sink mapping, I used automapping option.
I also tried with Copy activity. That didn't pan out. defining the cross apply signals the mapping is defined, turning off the automatic mapping.