The following query will not work:
Currently, the plan for this query, before SplitSparkWorkResolver, looks like below:
In SplitSparkWorkResolver#splitBaseWork, it assumes that the childWork is a ReduceWork, but for this case, you can see that for M2 the childWork could be UnionWork U3. Thus, the code will fail.
HIVE-9041 addressed partially addressed the problem by removing union task. However, it's still necessary to cloning M1 and M2 to support multi-insert. Because M1 and M2 can run in a single JVM, the original solution of storing a global IOContext will not work because M1 and M2 have different io contexts, both needing to be stored.