code: def apply_max_row_limit(
      limit: int, max_limit: Optional[int] = None
  ) -> int:
      if max_limit is None:
          max_limit = create_app_config()["SQL_MAX_ROW"]
      if limit != 0:
          return min(max_limit, limit)
      return max_limit
  
file_path: superset/tests/unit_tests/common/test_query_object_factory.py
imports: from typing import Any, Optional
  from unittest.mock import Mock, patch
  from pytest import fixture, mark
  from superset.common.query_object_factory import QueryObjectFactory
  from tests.common.query_context_generator import QueryContextGenerator
label_desc: Use image node_id 5 for calling a global function with example usage: apply_max_row_limit(limit, max_limit) and returns: max_limit, min