docstr: Returns the query with the specified limit.
  
  Does not change the underlying query if user did not apply the limit,
  otherwise replaces the limit with the lower value between existing limit
  in the query and new_limit.
  
  :param new_limit: Limit to be incorporated into returned query
  :return: The original query with new limit
code: def set_or_update_query_limit(
      self, new_limit: int, force: bool = False
  ) -> str:
      """Returns the query with the specified limit.
  
      Does not change the underlying query if user did not apply the limit,
      otherwise replaces the limit with the lower value between existing limit
      in the query and new_limit.
  
      :param new_limit: Limit to be incorporated into returned query
      :return: The original query with new limit
      """
      if not self._limit:
          return f"{self.stripped()}\nLIMIT {new_limit}"
      limit_pos = None
      statement = self._parsed[0]
      # Add all items to before_str until there is a limit
      for pos, item in enumerate(statement.tokens):
          if item.ttype in Keyword and item.value.lower() == "limit":
              limit_pos = pos
              break
      _, limit = statement.token_next(idx=limit_pos)
      # Override the limit only when it exceeds the configured value.
      if limit.ttype == sqlparse.tokens.Literal.Number.Integer and (
          force or new_limit < int(limit.value)
      ):
          limit.value = new_limit
      elif limit.is_group:
          limit.value = f"{next(limit.get_identifiers())}, {new_limit}"
  
      str_res = ""
      for i in statement.tokens:
          str_res += str(i.value)
      return str_res
  
imports: import logging
  import re
  from collections.abc import Iterator
  from dataclasses import dataclass
  from typing import Any, cast, Optional
  from urllib import parse
  import sqlparse
  from sqlalchemy import and_
  from sqlparse import keywords
  from sqlparse.lexer import Lexer
  from sqlparse.sql import Identifier, IdentifierList, Parenthesis, remove_quotes, Token, TokenList, Where
  from sqlparse.tokens import Comment, CTE, DDL, DML, Keyword, Name, Punctuation, String, Whitespace, Wildcard
  from sqlparse.utils import imt
  from superset.exceptions import QueryClauseValidationException
  from superset.utils.backports import StrEnum
label_desc: Use image node_id 22 for calling the ParsedQuery obj's underlying member method code with example usage: obj.set_or_update_query_limit(new_limit, force) and returns: str_res, self, str, new_limit