For Chris Drome:
CLI creates two levels of staging directories but calls setPermissions on the top-level directory only if hive.warehouse.subdir.inherit.perms=true.
The top-level directory, /user/cdrome/hive/words_text_dist/dt=c/.hive-staging_hive_2016-07-15_08-44-22_082_5534649671389063929-1 is created the first time Context.getExternalTmpPath is called.
The child directory, /user/cdrome/hive/words_text_dist/dt=c/.hive-staging_hive_2016-07-15_08-44-22_082_5534649671389063929-1/_tmp.-ext-10000 is created when TezTask.execute is called at line 164:
This calls DagUtils.createVertex, which calls Utilities.createTmpDirs:
It turns out that inheritPerms is no longer part of master. I'll rebase this for branch-2, and branch-2.2. master will have to wait till the issues around StorageBasedAuthProvider, directory permissions, etc. are sorted out.
(Note to self: YHIVE-857)