Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
Some related cleanup items to improve efficiency, snapshots, etc.
  • Loading branch information
courtneyholcomb committed Nov 14, 2024
1 parent e305b75 commit b291fc1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
13 changes: 7 additions & 6 deletions metricflow/dataflow/builder/dataflow_plan_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1482,10 +1482,12 @@ def __get_required_linkable_specs(
required_linkable_specs = queried_linkable_specs.merge(extraneous_linkable_specs).dedupe()

# Custom grains require joining to their base grain, so add base grain to extraneous specs.
base_grain_set = LinkableSpecSet.create_from_specs(
[spec.with_base_grain() for spec in required_linkable_specs.time_dimension_specs_with_custom_grain]
)
extraneous_linkable_specs = extraneous_linkable_specs.merge(base_grain_set).dedupe()
if required_linkable_specs.time_dimension_specs_with_custom_grain:
base_grain_set = LinkableSpecSet.create_from_specs(
[spec.with_base_grain() for spec in required_linkable_specs.time_dimension_specs_with_custom_grain]
)
extraneous_linkable_specs = extraneous_linkable_specs.merge(base_grain_set).dedupe()
required_linkable_specs = required_linkable_specs.merge(extraneous_linkable_specs).dedupe()

return required_linkable_specs

Expand Down Expand Up @@ -1761,15 +1763,14 @@ def _build_pre_aggregation_plan(
if measure_properties and measure_properties.non_additive_dimension_spec:
if queried_linkable_specs is None:
raise ValueError(
"`queried_linkable_specs` must be provided in _build_pre_aggregation_plan() if "
"`queried_linkable_specs` must be provided in when building pre-aggregation plan if "
"`non_additive_dimension_spec` is present."
)
output_node = self._build_semi_additive_join_node(
measure_properties=measure_properties,
queried_linkable_specs=queried_linkable_specs,
parent_node=output_node,
)

output_node = FilterElementsNode.create(
parent_node=output_node, include_specs=filter_to_specs, distinct=distinct
)
Expand Down
2 changes: 1 addition & 1 deletion metricflow/dataflow/builder/node_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def join_description(self) -> JoinDescription:
)

filtered_node_to_join = FilterElementsNode.create(
parent_node=self.node_to_join, include_specs=group_specs_by_type(include_specs)
parent_node=self.node_to_join, include_specs=group_specs_by_type(include_specs).dedupe()
)

return JoinDescription(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ FROM (
) subq_0
) subq_1
LEFT OUTER JOIN (
-- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing']
-- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing']
SELECT
subq_3.listing
, subq_3.is_lux_latest
Expand Down Expand Up @@ -841,7 +841,7 @@ FULL OUTER JOIN (
) subq_10
) subq_11
LEFT OUTER JOIN (
-- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing']
-- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing']
SELECT
subq_13.listing
, subq_13.is_lux_latest
Expand Down Expand Up @@ -1419,7 +1419,7 @@ FULL OUTER JOIN (
) subq_20
) subq_21
LEFT OUTER JOIN (
-- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing']
-- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing']
SELECT
subq_23.listing
, subq_23.is_lux_latest
Expand Down Expand Up @@ -1831,7 +1831,7 @@ FULL OUTER JOIN (
) subq_30
) subq_31
LEFT OUTER JOIN (
-- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing', 'listing']
-- Pass Only Elements: ['capacity_latest', 'is_lux_latest', 'listing']
SELECT
subq_33.listing
, subq_33.is_lux_latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ FROM (
) subq_0
) subq_1
LEFT OUTER JOIN (
-- Pass Only Elements: ['country_latest', 'is_lux_latest', 'listing', 'listing']
-- Pass Only Elements: ['country_latest', 'is_lux_latest', 'listing']
SELECT
subq_3.listing
, subq_3.country_latest
Expand Down

0 comments on commit b291fc1

Please sign in to comment.