code: public void setSessionUGI(String owner) throws HiveSQLException {
      if (owner == null) {
        throw new HiveSQLException("No username provided for impersonation");
      }
      if (UserGroupInformation.isSecurityEnabled()) {
        try {
          sessionUgi = UserGroupInformation.createProxyUser(
              owner, UserGroupInformation.getLoginUser());
        } catch (IOException e) {
          throw new HiveSQLException("Couldn't setup proxy user", e);
        }
      } else {
        sessionUgi = UserGroupInformation.createRemoteUser(owner);
      }
    }
docs: setup appropriate UGI for the session