private void processQuery(ScheduledQueryPollResponse q) {
      LOG.info("Executing schq:{}, executionId: {}", q.getScheduleKey().getScheduleName(), q.getExecutionId());
      info = new ScheduledQueryProgressInfo();
      info.setScheduledExecutionId(pollResponse.getExecutionId());
      info.setState(QueryState.EXECUTING);
      info.setExecutorQueryId(buildExecutorQueryId(""));
      SessionState state = null;
      try {
        HiveConf conf = new HiveConf(context.conf);
        conf.set(Constants.HIVE_QUERY_EXCLUSIVE_LOCK, lockNameFor(q.getScheduleKey()));
        conf.setVar(HiveConf.ConfVars.HIVE_AUTHENTICATOR_MANAGER, SessionStateUserAuthenticator.class.getName());
        conf.set(Constants.SCHEDULED_QUERY_NAMESPACE, q.getScheduleKey().getClusterNamespace());
        conf.set(Constants.SCHEDULED_QUERY_SCHEDULENAME, q.getScheduleKey().getScheduleName());
        conf.set(Constants.SCHEDULED_QUERY_USER, q.getUser());
        conf.set(Constants.SCHEDULED_QUERY_EXECUTIONID, Long.toString(q.getExecutionId()));
        conf.unset(HiveConf.ConfVars.HIVE_SESSION_ID.varname);
        state = new SessionState(conf, q.getUser());
        state.setIsHiveServerQuery(true);
        SessionState.start(state);
        reportQueryProgress();
        try (
          IDriver driver = DriverFactory.newDriver(DriverFactory.getNewQueryState(conf), null)) {
          info.setExecutorQueryId(buildExecutorQueryId(driver));
          reportQueryProgress();
          driver.run(q.getQuery());
          info.setState(QueryState.FINISHED);
        }
      } catch (Throwable t) {
        info.setErrorMessage(getErrorStringForException(t));
        info.setState(QueryState.FAILED);
      } finally {
        if (state != null) {
          try {
            state.close();
          } catch (Throwable e) {
          }
        }
        reportQueryProgress();
      }
    }
Responsible for a single execution of a scheduled query.

The execution happens in a separate thread.
ql/src/java/org/apache/hadoop/hive/ql/scheduled/ScheduledQueryExecutionService.java