class_docstr: Checks to see if a join between two semantic models should be allowed.
class_docstr_tok: ["Checks","to","see","if","a","join","between","two","semantic","models","should","be","allowed","."]
docstr: Return the semantic model where the entity was defined in the instance set.
docstr_tok: ["Return","the","semantic","model","where","the","entity","was","defined","in","the","instance","set","."]
code: def _semantic_model_of_entity_in_instance_set(
      instance_set: InstanceSet,
      entity_reference: EntityReference,
  ) -> SemanticModelReference:
      """Return the semantic model where the entity was defined in the instance set."""
      matching_instances: List[EntityInstance] = []
      for entity_instance in instance_set.entity_instances:
          assert len(entity_instance.defined_from) == 1
          if (
              len(entity_instance.spec.entity_links) == 0
              and entity_instance.spec.reference == entity_reference
          ):
              matching_instances.append(entity_instance)
  
      assert len(matching_instances) == 1, (
          f"Not exactly 1 matching entity instances found: {matching_instances} for {entity_reference} in "
          f"{pformat_big_objects(instance_set)}"
      )
      return matching_instances[
          0
      ].origin_semantic_model_reference.semantic_model_reference
  
file_path: metricflow/metricflow/model/semantics/semantic_model_join_evaluator.py
imports: from __future__ import annotations
  from dataclasses import dataclass
  from typing import Dict, List, Optional
  from dbt_semantic_interfaces.pretty_print import pformat_big_objects
  from dbt_semantic_interfaces.protocols.entity import EntityType
  from dbt_semantic_interfaces.references import EntityReference, SemanticModelElementReference, SemanticModelReference
  from metricflow.instances import EntityInstance, InstanceSet
  from metricflow.protocols.semantics import SemanticModelAccessor
label_desc: Use image node_id 6 for calling the SemanticModelJoinEvaluator obj's underlying member method code with example usage: obj._semantic_model_of_entity_in_instance_set(instance_set, entity_reference) and returns: matching_instances