@Override
  public void cancel() throws SQLException {
    checkConnection("cancel");
    if (isCancelled) {
      return;
    }

    try {
      if (stmtHandle.isPresent()) {
        TCancelOperationReq cancelReq = new TCancelOperationReq(stmtHandle.get());
        TCancelOperationResp cancelResp = client.CancelOperation(cancelReq);
        Utils.verifySuccessWithInfo(cancelResp.getStatus());
      }
    } catch (SQLException e) {
      throw e;
    } catch (Exception e) {
      throw new SQLException("Failed to cancel statement", "08S01", e);
    }
    isCancelled = true;
  }
Keep this state so we can know whether the query logs are being generated in HS2.
jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java