fix nullpointer cause by auto join conversion

Summary:
HIVE-4927
HIVE 4521 Auto join conversion fails in certain cases (empty tables, empty partitions, no partitions)
HIVE-4540 JOIN-GRP BY-DISTINCT fails with NPE when mapjoin.mapreduce=true

Merge branch 'nullpointer' into nullpointer_fix

Test Plan: none

Reviewers: chenchun

CC: xieyuchen

Differential Revision: http://192.168.2.241/D413