fix Union Query result merging

this will probably have some impacts on performance, but hopefully things are tolerable, otherwise we will have to start considering doing merging on the compute node side