DP-129: back port HIVE-3826 fix into hive 0.10

I built this with both hadoop 2.0.2 and 2.0.5 and all desktop hive tests still pass.