DONT MERGE : applying patch HIVE-4996 for testing