Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed May 7, 2024
1 parent 0cd61b4 commit 077c769
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,7 @@ def derived_from_semantic_models(self) -> Sequence[SemanticModelReference]:
Includes semantic models used in the join paths for both the inner and outer queries (if applicable),
plus the semantic models the metric's measure(s) originated from.
"""
semantic_model_references = set(
self.join_path.metric_subquery_join_path_element.metric_derived_from_semantic_models
)
semantic_model_references = set(self.join_path.metric_subquery_join_path_element.derived_from_semantic_models)
if self.join_path.semantic_model_join_path:
semantic_model_references.update(self.join_path.semantic_model_join_path.derived_from_semantic_models)
if self.metric_to_entity_join_path:
Expand Down Expand Up @@ -301,6 +299,7 @@ class MetricSubqueryJoinPathElement:
Args:
metric_reference: The metric that's aggregated in the subquery.
derived_from_semantic_models: The semantic models that the measure's input metrics are defined in.
join_on_entity: The entity that the metric is grouped by in the subquery. This will be updated in V2 to allow a list
of entitites & dimensions.
entity_links: Sequence of entities joined to get from a metric source to the `join_on_entity`.
Expand All @@ -309,14 +308,14 @@ class MetricSubqueryJoinPathElement:
"""

metric_reference: MetricReference
metric_derived_from_semantic_models: Tuple[SemanticModelReference, ...]
derived_from_semantic_models: Tuple[SemanticModelReference, ...]
join_on_entity: EntityReference
entity_links: Tuple[EntityReference, ...]
metric_to_entity_join_path: Optional[SemanticModelJoinPath] = None

def __post_init__(self) -> None: # noqa: D105
assert (
self.metric_derived_from_semantic_models
self.derived_from_semantic_models
), "There must be at least one semantic model from which the metric is derived."


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def __init__(
for linkable_entity in linkable_entities:
metric_subquery_join_path_element = MetricSubqueryJoinPathElement(
metric_reference=metric_reference,
metric_derived_from_semantic_models=defined_from_semantic_models,
derived_from_semantic_models=defined_from_semantic_models,
join_on_entity=linkable_entity.reference,
entity_links=linkable_entity.entity_links,
metric_to_entity_join_path=(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
join_path=SemanticModelToMetricSubqueryJoinPath(
metric_subquery_join_path_element=MetricSubqueryJoinPathElement(
metric_reference=_base_metric_reference,
metric_derived_from_semantic_models=(_metric_semantic_model,),
derived_from_semantic_models=(_metric_semantic_model,),
join_on_entity=_base_entity_reference,
entity_links=(_base_entity_reference,),
),
Expand All @@ -148,7 +148,7 @@
join_path=SemanticModelToMetricSubqueryJoinPath(
metric_subquery_join_path_element=MetricSubqueryJoinPathElement(
metric_reference=MetricReference(AMBIGUOUS_NAME),
metric_derived_from_semantic_models=(_metric_semantic_model,),
derived_from_semantic_models=(_metric_semantic_model,),
join_on_entity=_base_entity_reference,
entity_links=(_base_entity_reference,),
),
Expand All @@ -160,7 +160,7 @@
join_path=SemanticModelToMetricSubqueryJoinPath(
metric_subquery_join_path_element=MetricSubqueryJoinPathElement(
metric_reference=MetricReference(AMBIGUOUS_NAME),
metric_derived_from_semantic_models=(_metric_semantic_model,),
derived_from_semantic_models=(_metric_semantic_model,),
join_on_entity=_base_entity_reference,
entity_links=(_base_entity_reference,),
),
Expand Down Expand Up @@ -632,7 +632,7 @@ def linkable_set() -> LinkableElementSet: # noqa: D103
join_path=SemanticModelToMetricSubqueryJoinPath(
metric_subquery_join_path_element=MetricSubqueryJoinPathElement(
metric_reference=MetricReference("metric_element"),
metric_derived_from_semantic_models=(_metric_semantic_model,),
derived_from_semantic_models=(_metric_semantic_model,),
join_on_entity=entity_3,
entity_links=(entity_3, entity_4),
metric_to_entity_join_path=SemanticModelJoinPath(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ def test_metric_in_filter( # noqa: D103
join_path=SemanticModelToMetricSubqueryJoinPath(
metric_subquery_join_path_element=MetricSubqueryJoinPathElement(
metric_reference=MetricReference("bookings"),
metric_derived_from_semantic_models=(SemanticModelReference("bookings"),),
derived_from_semantic_models=(SemanticModelReference("bookings"),),
join_on_entity=EntityReference("listing"),
entity_links=(EntityReference("listing"),),
)
Expand Down

0 comments on commit 077c769

Please sign in to comment.