HIVE-8406: copy logic from MapJoinResolver