Skip to content

Commit

Permalink
Fix bug related to sorting columns in snapshots
Browse files Browse the repository at this point in the history
This sorting was not commprehensive and resulted in inconsistent snapshots. Removed the custom sorting here and retained the original order, instead.
  • Loading branch information
courtneyholcomb committed Dec 9, 2024
1 parent 5a58307 commit c7aa673
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions metricflow/plan_conversion/dataflow_to_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,16 +325,16 @@ def _make_time_spine_data_set(
"""
time_spine_table_alias = self._next_unique_table_alias()

queried_specs = {instance.spec for instance in agg_time_dimension_instances}
specs_required_for_where_constraints = {
queried_specs = [instance.spec for instance in agg_time_dimension_instances]
queried_specs_set = set(queried_specs)
specs_required_for_where_constraints = [
spec
for constraint in time_spine_where_constraints
for spec in constraint.linkable_spec_set.time_dimension_specs
}
required_specs = sorted( # sorted for consistency in snapshots
queried_specs.union(specs_required_for_where_constraints),
key=lambda spec: (spec.element_name, spec.time_granularity.base_granularity.to_int()),
)
if spec not in queried_specs_set
]
required_specs = queried_specs + specs_required_for_where_constraints

time_spine_sources = TimeSpineSource.choose_time_spine_sources(
required_time_spine_specs=required_specs, time_spine_sources=self._time_spine_sources
)
Expand Down

0 comments on commit c7aa673

Please sign in to comment.