@LimitedPrivate(value={"Hive and closely related projects."})
  public String getQueryId() throws SQLException {
    // Storing it in temp variable as this method is not thread-safe and concurrent thread can
    // close this handle and set it to null after checking for null.
    TOperationHandle stmtHandleTmp = stmtHandle.orElse(null);
    if (stmtHandleTmp == null) {
      // If query is not running or already closed.
      return null;
    }
    try {
      final String queryId = client.GetQueryId(new TGetQueryIdReq(stmtHandleTmp)).getQueryId();

      // queryId can be empty string if query was already closed. Need to return null in such case.
      return StringUtils.isBlank(queryId) ? null : queryId;
    } catch (TException e) {
      throw new SQLException(e);
    }
  }
Returns the Query ID if it is running. This method is a public API for
usage outside of Hive, although it is not part of the interface
java.sql.Statement.

@return Valid query ID if it is running else returns NULL.
@throws SQLException If any internal failures.
jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java