code: def test_sql_lab_insert_rls_as_subquery(
      mocker: MockerFixture,
      session: Session,
  ) -> None:
      """
      Integration test for `insert_rls_as_subquery`.
      """
      from flask_appbuilder.security.sqla.models import Role, User
  
      from superset.connectors.sqla.models import (
          RowLevelSecurityFilter,
          SqlaTable,
      )
      from superset.models.core import Database
      from superset.models.sql_lab import Query
      from superset.security.manager import SupersetSecurityManager
      from superset.sql_lab import execute_sql_statement
      from superset.utils.core import RowLevelSecurityFilterType
  
      engine = session.connection().engine
      Query.metadata.create_all(engine)  # pylint: disable=no-member
  
      connection = engine.raw_connection()
      connection.execute("CREATE TABLE t (c INTEGER)")
      for i in range(10):
          connection.execute("INSERT INTO t VALUES (?)", (i,))
  
      cursor = connection.cursor()
  
      query = Query(
          sql="SELECT c FROM t",
          client_id="abcde",
          database=Database(
              database_name="test_db", sqlalchemy_uri="sqlite://"
          ),
          schema=None,
          limit=5,
          select_as_cta_used=False,
      )
      session.add(query)
      session.commit()
  
      admin = User(
          first_name="Alice",
          last_name="Doe",
          email="adoe@example.org",
          username="admin",
          roles=[Role(name="Admin")],
      )
  
      # first without RLS
      with override_user(admin):
          superset_result_set = execute_sql_statement(
              sql_statement=query.sql,
              query=query,
              cursor=cursor,
              log_params=None,
              apply_ctas=False,
          )
      assert (
          superset_result_set.to_pandas_df().to_markdown()
          == """
  |    |   c |
  |---:|----:|
  |  0 |   0 |
  |  1 |   1 |
  |  2 |   2 |
  |  3 |   3 |
  |  4 |   4 |""".strip()
      )
      assert query.executed_sql == "SELECT c FROM t\nLIMIT 6"
  
      # now with RLS
      rls = RowLevelSecurityFilter(
          name="sqllab_rls1",
          filter_type=RowLevelSecurityFilterType.REGULAR,
          tables=[
              SqlaTable(database_id=1, schema=None, table_name="t")
          ],
          roles=[admin.roles[0]],
          group_key=None,
          clause="c > 5",
      )
      session.add(rls)
      session.flush()
      mocker.patch.object(
          SupersetSecurityManager, "find_user", return_value=admin
      )
      mocker.patch(
          "superset.sql_lab.is_feature_enabled", return_value=True
      )
  
      with override_user(admin):
          superset_result_set = execute_sql_statement(
              sql_statement=query.sql,
              query=query,
              cursor=cursor,
              log_params=None,
              apply_ctas=False,
          )
      assert (
          superset_result_set.to_pandas_df().to_markdown()
          == """
  |    |   c |
  |---:|----:|
  |  0 |   6 |
  |  1 |   7 |
  |  2 |   8 |
  |  3 |   9 |""".strip()
      )
      assert (
          query.executed_sql
          == "SELECT c FROM (SELECT * FROM t WHERE (t.c > 5)) AS t\nLIMIT 6"
      )
  
file_path: superset/tests/unit_tests/sql_lab_test.py
imports: import sqlparse
  from pytest_mock import MockerFixture
  from sqlalchemy.orm.session import Session
  from superset import db
  from superset.utils.core import override_user
label_desc: Use image node_id 3 for calling a global function with example usage: test_sql_lab_insert_rls_as_subquery(mocker, session) without return types