@Override
  public TExecuteStatementResp ExecuteStatement(TExecuteStatementReq req) throws TException {
    TExecuteStatementResp resp = new TExecuteStatementResp();
    try {
      SessionHandle sessionHandle = new SessionHandle(req.getSessionHandle());
      String statement = req.getStatement();
      Map<String, String> confOverlay = req.getConfOverlay();
      Boolean runAsync = req.isRunAsync();
      long queryTimeout = req.getQueryTimeout();
      OperationHandle operationHandle =
          runAsync ? cliService.executeStatementAsync(sessionHandle, statement, confOverlay,
              queryTimeout) : cliService.executeStatement(sessionHandle, statement, confOverlay,
              queryTimeout);
      resp.setOperationHandle(operationHandle.toTOperationHandle());
      SessionManager sessionManager = cliService.getSessionManager();
      if (sessionManager.getOperationManager().canShowDrilldownLink(operationHandle)) {
        StringBuilder urlBuilder = new StringBuilder("The url to track the statement: ")
            .append(hiveConf.getBoolVar(HiveConf.ConfVars.HIVE_SERVER2_WEBUI_USE_SSL) ? "https" : "http")
            .append("://")
            .append(sessionManager.getHiveServer2HostName())
            .append(":")
            .append(hiveConf.getIntVar(HiveConf.ConfVars.HIVE_SERVER2_WEBUI_PORT))
            .append("/query_page.html?operationId=")
            .append(operationHandle.getHandleIdentifier().toString());
        TStatus successWithInfo = new TStatus(TStatusCode.SUCCESS_WITH_INFO_STATUS);
        successWithInfo.addToInfoMessages(urlBuilder.toString());
        resp.setStatus(successWithInfo);
      } else {
        resp.setStatus(OK_STATUS);
      }
    } catch (Exception e) {
      // Note: it's rather important that this (and other methods) catch Exception, not Throwable;
      // in combination with HiveSessionProxy.invoke code, perhaps unintentionally, it used
      // to also catch all errors; and now it allows OOMs only to propagate.
      LOG.error("Failed to execute statement [request: {}]", req, e);
      resp.setStatus(HiveSQLException.toTStatus(e));
    }
    return resp;
  }
Create a session handle
@param req
@param res
@return
@throws HiveSQLException
@throws LoginException
@throws IOException
service/src/java/org/apache/hive/service/cli/thrift/ThriftCLIService.java