Skip to content

Commit

Permalink
Add back join_targets shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed Nov 11, 2023
1 parent 153e36d commit 2b03b83
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
17 changes: 11 additions & 6 deletions metricflow/dataflow/builder/dataflow_plan_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
ConstrainTimeRangeNode,
DataflowPlan,
FilterElementsNode,
JoinDescription,
JoinOverTimeRangeNode,
JoinToBaseOutputNode,
JoinToTimeSpineNode,
Expand Down Expand Up @@ -76,6 +77,11 @@ class DataflowRecipe:
required_local_linkable_specs: Tuple[LinkableInstanceSpec, ...]
join_linkable_instances_recipes: Tuple[JoinLinkableInstancesRecipe, ...]

@property
def join_targets(self) -> List[JoinDescription]:
"""Joins to be made to source node."""
return [join_recipe.join_description for join_recipe in self.join_linkable_instances_recipes]


@dataclass(frozen=True)
class MeasureSpecProperties:
Expand Down Expand Up @@ -258,11 +264,10 @@ def build_plan_for_distinct_values(self, query_spec: MetricFlowQuerySpec) -> Dat
raise UnableToSatisfyQueryError(f"Recipe not found for linkable specs: {query_spec.linkable_specs}")

joined_node: Optional[JoinToBaseOutputNode] = None
if dataflow_recipe.join_linkable_instances_recipes:
join_targets = [
join_recipe.join_description for join_recipe in dataflow_recipe.join_linkable_instances_recipes
]
joined_node = JoinToBaseOutputNode(left_node=dataflow_recipe.source_node, join_targets=join_targets)
if dataflow_recipe.join_targets:
joined_node = JoinToBaseOutputNode(
left_node=dataflow_recipe.source_node, join_targets=dataflow_recipe.join_targets
)

where_constraint_node: Optional[WhereConstraintNode] = None
if query_spec.where_constraint:
Expand Down Expand Up @@ -739,7 +744,7 @@ def _build_aggregated_measure_from_measure_source_node(
),
)

join_targets = [join_recipe.join_description for join_recipe in measure_recipe.join_linkable_instances_recipes]
join_targets = measure_recipe.join_targets
unaggregated_measure_node: BaseOutput
if len(join_targets) > 0:
filtered_measures_with_joined_elements = JoinToBaseOutputNode(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<!-- description = -->
<!-- Pass Only Elements: -->
<!-- ['user__home_state_latest', 'listing__is_lux_latest'] -->
<!-- node_id = pfe_1 -->
<!-- node_id = pfe_2 -->
<!-- include_spec = -->
<!-- {'class': 'DimensionSpec', -->
<!-- 'element_name': 'home_state_latest', -->
Expand All @@ -44,9 +44,9 @@
<JoinToBaseOutputNode>
<!-- description = Join Standard Outputs -->
<!-- node_id = jso_0 -->
<!-- join0_for_node_id_pfe_0 = -->
<!-- join0_for_node_id_pfe_1 = -->
<!-- {'class': 'JoinDescription', -->
<!-- 'join_node': FilterElementsNode(node_id=pfe_0), -->
<!-- 'join_node': FilterElementsNode(node_id=pfe_1), -->
<!-- 'join_on_entity': {'class': 'LinklessEntitySpec', -->
<!-- 'element_name': 'user', -->
<!-- 'entity_links': ()}, -->
Expand All @@ -65,7 +65,7 @@
<!-- description = -->
<!-- Pass Only Elements: -->
<!-- ['home_state_latest', 'user'] -->
<!-- node_id = pfe_0 -->
<!-- node_id = pfe_1 -->
<!-- include_spec = -->
<!-- {'class': 'DimensionSpec', -->
<!-- 'element_name': 'home_state_latest', -->
Expand Down

0 comments on commit 2b03b83

Please sign in to comment.