Apply patches for HIVE-7623, and HIVE-3815 (applied manually due to the line number mismatch, but the change is trivial)

https://issues.apache.org/jira/secure/attachment/12561529/HIVE-3815.1.patch
https://issues.apache.org/jira/secure/attachment/12660949/HIVE-7623.1.patch.txt