public static HiveSession getProxy(HiveSession hiveSession, UserGroupInformation ugi)
      throws IllegalArgumentException, HiveSQLException {
    return (HiveSession)Proxy.newProxyInstance(HiveSession.class.getClassLoader(),
        new Class<?>[] {HiveSession.class},
        new HiveSessionProxy(hiveSession, ugi));
  }
Proxy wrapper on HiveSession to execute operations
by impersonating given user
service/src/java/org/apache/hive/service/cli/session/HiveSessionProxy.java