private void enrichFromSessionState(Record record) {
    record.setSessionId(sessionState.getSessionId());
    record.setEndUser(sessionState.getUserName());
    record.setClientProtocol(sessionState.getConf().getInt(SerDeUtils.LIST_SINK_OUTPUT_PROTOCOL, 0));
    try {
      boolean doAsEnabled = sessionState.getConf().getBoolVar(HiveConf.ConfVars.HIVE_SERVER2_ENABLE_DOAS);
      String user = Utils.getUGI().getShortUserName();
      record.setClusterUser(doAsEnabled ? sessionState.getUserName() : user);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    record.setSessionType(
        sessionState.isHiveServerQuery() ? SessionType.HIVESERVER2.name() :
            SessionType.OTHER.name());
    record.setCurrentDatabase(sessionState.getCurrentDatabase());
    record.setClientAddress(sessionState.getUserIpAddress());
    record.setConfigurationOptionsChanged(sessionState.getOverriddenConfigurations());
  }
With query history, a more detailed HiveOperation-based query classification is introduced without breaking the
original one. If there is an SqlKind stored in the QueryState, the record will contain it.
ql/src/java/org/apache/hadoop/hive/ql/queryhistory/RecordEnricher.java