I want to Union/Merge two files using pig. But, this is a different union than a usual union. Following are my files (h\* are header of files) : 

```
F1 : 
h1,h2,h3,h4
a01,a02,a03,a04
a11,a12,a13,a14

F2 : 
h3,h4,h5,h6
a23,a24,b01,b02
a33,a34,b11,b12

```

The resulting output must be a Union of these files like this :

```
FR :
h1,h2,h3,h4,h5,h6 
a01,a02,a03,a04,,
a11,a12,a13,a14,,
,,a23,a24,b01,b02
,,a33,a34,b11,b12

```

One more difficulty is I want to make it generic so that it works for dynamic number of common columns. Currently there are two common columns, it could have 3 or 1 common column or even no common column at all. For example :

```
F1 :
h1,h2,h3,h4
a1,a2,a3,a4

F2
h5,h6,h7,h8
b1,b2,b3,b4

FR
a1,a2,a3,a4
,,,,b1,b2,b3,b4

```

Any hint/help is appreciable.