code: def test_case(
      name: str,
      mf_test_session_state: MetricFlowTestSessionState,
      simple_semantic_manifest_lookup: SemanticManifestLookup,
      simple_semantic_manifest_lookup_non_ds: SemanticManifestLookup,
      unpartitioned_multi_hop_join_semantic_manifest_lookup: SemanticManifestLookup,
      multi_hop_join_semantic_manifest_lookup: SemanticManifestLookup,
      extended_date_semantic_manifest_lookup: SemanticManifestLookup,
      scd_semantic_manifest_lookup: SemanticManifestLookup,
      sql_client: SqlClient,
      create_source_tables: bool,
  ) -> None:
      """Runs all integration tests configured in the test case YAML directory."""
      case = CONFIGURED_INTEGRATION_TESTS_REPOSITORY.get_test_case(name)
      logger.info(
          f"Running integration test case: '{case.name}' from file '{case.file_path}'"
      )
  
      missing_required_features = filter_not_supported_features(
          sql_client, case.required_features
      )
      if missing_required_features:
          pytest.skip(
              f"DW does not support {missing_required_features}"
          )
  
      semantic_manifest_lookup: Optional[SemanticManifestLookup] = None
      if case.model is IntegrationTestModel.SIMPLE_MODEL:
          semantic_manifest_lookup = simple_semantic_manifest_lookup
      elif case.model is IntegrationTestModel.SIMPLE_MODEL_NON_DS:
          semantic_manifest_lookup = (
              simple_semantic_manifest_lookup_non_ds
          )
      elif (
          case.model
          is IntegrationTestModel.UNPARTITIONED_MULTI_HOP_JOIN_MODEL
      ):
          semantic_manifest_lookup = (
              unpartitioned_multi_hop_join_semantic_manifest_lookup
          )
      elif (
          case.model
          is IntegrationTestModel.PARTITIONED_MULTI_HOP_JOIN_MODEL
      ):
          semantic_manifest_lookup = (
              multi_hop_join_semantic_manifest_lookup
          )
      elif case.model is IntegrationTestModel.EXTENDED_DATE_MODEL:
          semantic_manifest_lookup = (
              extended_date_semantic_manifest_lookup
          )
      elif case.model is IntegrationTestModel.SCD_MODEL:
          semantic_manifest_lookup = scd_semantic_manifest_lookup
      else:
          assert_values_exhausted(case.model)
  
      assert semantic_manifest_lookup
  
      engine = MetricFlowEngine(
          semantic_manifest_lookup=semantic_manifest_lookup,
          sql_client=sql_client,
          column_association_resolver=DunderColumnAssociationResolver(
              semantic_manifest_lookup
          ),
          time_source=ConfigurableTimeSource(as_datetime("2021-01-04")),
      )
  
      check_query_helpers = CheckQueryHelpers(sql_client)
  
      group_by: List[DimensionOrEntityQueryParameter] = []
      for group_by_kwargs in case.group_by_objs:
          kwargs = copy(group_by_kwargs)
          date_part = kwargs.get("date_part")
          grain = kwargs.get("grain")
          if date_part or grain:
              if date_part:
                  kwargs["date_part"] = DatePart(date_part)
              if grain:
                  kwargs["grain"] = TimeGranularity(grain)
              group_by.append(TimeDimensionParameter(**kwargs))
          else:
              group_by.append(DimensionOrEntityParameter(**kwargs))
      query_result = engine.query(
          MetricFlowQueryRequest.create_with_random_request_id(
              metric_names=case.metrics,
              group_by_names=case.group_bys
              if len(case.group_bys) > 0
              else None,
              group_by=tuple(group_by) if len(group_by) > 0 else None,
              limit=case.limit,
              time_constraint_start=parser.parse(
                  case.time_constraint[0]
              )
              if case.time_constraint
              else None,
              time_constraint_end=parser.parse(case.time_constraint[1])
              if case.time_constraint
              else None,
              where_constraint=jinja2.Template(
                  case.where_filter,
                  undefined=jinja2.StrictUndefined,
              ).render(
                  source_schema=mf_test_session_state.mf_source_schema,
                  render_time_constraint=check_query_helpers.render_time_constraint,
                  render_between_time_constraint=check_query_helpers.render_between_time_constraint,
                  TimeGranularity=TimeGranularity,
                  DatePart=DatePart,
                  render_date_sub=check_query_helpers.render_date_sub,
                  render_date_trunc=check_query_helpers.render_date_trunc,
                  render_extract=check_query_helpers.render_extract,
                  render_percentile_expr=check_query_helpers.render_percentile_expr,
                  mf_time_spine_source=semantic_manifest_lookup.time_spine_source.spine_table.sql,
                  double_data_type_name=check_query_helpers.double_data_type_name,
                  render_dimension_template=check_query_helpers.render_dimension_template,
                  render_entity_template=check_query_helpers.render_entity_template,
                  render_time_dimension_template=check_query_helpers.render_time_dimension_template,
                  generate_random_uuid=check_query_helpers.generate_random_uuid,
                  cast_to_ts=check_query_helpers.cast_to_ts,
              )
              if case.where_filter
              else None,
              order_by_names=case.order_bys,
              min_max_only=case.min_max_only,
          )
      )
  
      actual = query_result.result_df
  
      expected = sql_client.query(
          jinja2.Template(
              case.check_query,
              undefined=jinja2.StrictUndefined,
          ).render(
              source_schema=mf_test_session_state.mf_source_schema,
              render_time_constraint=check_query_helpers.render_time_constraint,
              render_between_time_constraint=check_query_helpers.render_between_time_constraint,
              TimeGranularity=TimeGranularity,
              DatePart=DatePart,
              render_date_sub=check_query_helpers.render_date_sub,
              render_date_trunc=check_query_helpers.render_date_trunc,
              render_extract=check_query_helpers.render_extract,
              render_percentile_expr=check_query_helpers.render_percentile_expr,
              mf_time_spine_source=semantic_manifest_lookup.time_spine_source.spine_table.sql,
              double_data_type_name=check_query_helpers.double_data_type_name,
              generate_random_uuid=check_query_helpers.generate_random_uuid,
              cast_to_ts=check_query_helpers.cast_to_ts,
          )
      )
      # If we sort, it's effectively not checking the order whatever order that the output was would be overwritten.
      assert_dataframes_equal(
          actual,
          expected,
          sort_columns=not case.check_order,
          allow_empty=case.allow_empty,
      )
  
imports: from __future__ import annotations
  import datetime
  import logging
  from copy import copy
  from typing import List, Optional, Sequence, Tuple
  import jinja2
  import pytest
  from dateutil import parser
  from dbt_semantic_interfaces.enum_extension import assert_values_exhausted
  from dbt_semantic_interfaces.implementations.elements.measure import PydanticMeasureAggregationParameters
  from dbt_semantic_interfaces.test_utils import as_datetime
  from dbt_semantic_interfaces.type_enums.date_part import DatePart
  from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity
  from metricflow.engine.metricflow_engine import MetricFlowEngine, MetricFlowQueryRequest
  from metricflow.model.semantic_manifest_lookup import SemanticManifestLookup
  from metricflow.plan_conversion.column_resolver import DunderColumnAssociationResolver
  from metricflow.protocols.query_parameter import DimensionOrEntityQueryParameter
  from metricflow.protocols.sql_client import SqlClient
  from metricflow.specs.query_param_implementations import DimensionOrEntityParameter, TimeDimensionParameter
  from metricflow.sql.sql_exprs import SqlCastToTimestampExpression, SqlColumnReference, SqlColumnReferenceExpression, SqlDateTruncExpression, SqlExtractExpression, SqlGenerateUuidExpression, SqlPercentileExpression, SqlPercentileExpressionArgument, SqlPercentileFunctionType, SqlStringExpression, SqlSubtractTimeIntervalExpression
  from metricflow.test.compare_df import assert_dataframes_equal
  from metricflow.test.fixtures.setup_fixtures import MetricFlowTestSessionState
  from metricflow.test.integration.configured_test_case import CONFIGURED_INTEGRATION_TESTS_REPOSITORY, IntegrationTestModel, RequiredDwEngineFeatures
  from metricflow.test.time.configurable_time_source import ConfigurableTimeSource
label_desc: Use image node_id 2 for calling a global function with example usage: test_case(name, mf_test_session_state, simple_semantic_manifest_lookup, simple_semantic_manifest_lookup_non_ds, unpartitioned_multi_hop_join_semantic_manifest_lookup, multi_hop_join_semantic_manifest_lookup, extended_date_semantic_manifest_lookup, scd_semantic_manifest_lookup, sql_client, create_source_tables) without return types