Consider the arrays as shown here. I have 3 sets of array:
Array 1:
C1 C2 C3 1 2 3 9 5 6
Array 2:
C2 C3 C
Here's the version in scala -
https://stackoverflow.com/a/60702657/9445912
On question-
Spark - Merge / Union DataFrame with Different Schema (column names and sequence) to a DataFrame with Master common schema