code: public static void createStagingDirectory(FileSystem fs, String destination, HiveProcessingEntity conversionEntity,
        WorkUnitState workUnit) {
      /*
       * Create staging data location with the same permissions as source data location
       *
       * Note that hive can also automatically create the non-existing directories but it does not
       * seem to create it with the desired permissions.
       * According to hive docs permissions for newly created directories/files can be controlled using uMask like,
       *
       * SET hive.warehouse.subdir.inherit.perms=false;
       * SET fs.permissions.umask-mode=022;
       * Upon testing, this did not work
       */
      Path destinationPath = new Path(destination);
      try {
        FsPermission permission;
        String group = null;
        if (conversionEntity.getTable().getDataLocation() != null) {
          FileStatus sourceDataFileStatus = fs.getFileStatus(conversionEntity.getTable().getDataLocation());
          permission = sourceDataFileStatus.getPermission();
          group = sourceDataFileStatus.getGroup();
        } else {
          permission = FsPermission.getDefault();
        }
  
        if (!fs.mkdirs(destinationPath, permission)) {
          throw new RuntimeException(String.format("Failed to create path %s with permissions %s",
              destinationPath, permission));
        } else {
          fs.setPermission(destinationPath, permission);
          // Set the same group as source
          if (group != null && !workUnit.getPropAsBoolean(HIVE_DATASET_DESTINATION_SKIP_SETGROUP, DEFAULT_HIVE_DATASET_DESTINATION_SKIP_SETGROUP)) {
            fs.setOwner(destinationPath, null, group);
          }
          log.info(String.format("Created %s with permissions %s and group %s", destinationPath, permission, group));
        }
      } catch (IOException e) {
        Throwables.propagate(e);
      }
    }
docs: Creates a staging directory with the permission as in source directory.
  @param fs filesystem object
  @param destination staging directory location
  @param conversionEntity conversion entity used to get source directory permissions
  @param workUnit workunit