Skip to content

Commit

Permalink
Rename TimeSpineSource.create_from_manifest() to build_standard_time_…
Browse files Browse the repository at this point in the history
…spine_sources()

This will help differentiate from a new method that builds custom time spine sources
  • Loading branch information
courtneyholcomb committed Aug 29, 2024
1 parent e801969 commit 952cc5a
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def __init__(
# Sort semantic models by name for consistency in building derived objects.
self._semantic_models = sorted(self._semantic_manifest.semantic_models, key=lambda x: x.name)
self._join_evaluator = SemanticModelJoinEvaluator(semantic_model_lookup)
self._time_spine_sources = TimeSpineSource.create_from_manifest(self._semantic_manifest)
self._time_spine_sources = TimeSpineSource.build_standard_time_spine_sources(self._semantic_manifest)

assert max_entity_links >= 0
self._max_entity_links = max_entity_links
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ def spine_table(self) -> SqlTable:
return SqlTable(schema_name=self.schema_name, table_name=self.table_name, db_name=self.db_name)

@staticmethod
def create_from_manifest(semantic_manifest: SemanticManifest) -> Dict[TimeGranularity, TimeSpineSource]:
def build_standard_time_spine_sources(
semantic_manifest: SemanticManifest,
) -> Dict[TimeGranularity, TimeSpineSource]:
"""Creates a time spine source based on what's in the manifest."""
time_spine_sources = {
time_spine.primary_column.time_granularity: TimeSpineSource(
Expand Down
2 changes: 1 addition & 1 deletion metricflow/dataflow/builder/source_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__( # noqa: D107
self._semantic_manifest_lookup = semantic_manifest_lookup
data_set_converter = SemanticModelToDataSetConverter(column_association_resolver)
self._time_spine_source_nodes = {}
for granularity, time_spine_source in TimeSpineSource.create_from_manifest(
for granularity, time_spine_source in TimeSpineSource.build_standard_time_spine_sources(
semantic_manifest_lookup.semantic_manifest
).items():
data_set = data_set_converter.build_time_spine_source_data_set(time_spine_source)
Expand Down
4 changes: 3 additions & 1 deletion metricflow/engine/metricflow_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,9 @@ def __init__(
DunderColumnAssociationResolver(semantic_manifest_lookup)
)
self._time_source = time_source
self._time_spine_sources = TimeSpineSource.create_from_manifest(semantic_manifest_lookup.semantic_manifest)
self._time_spine_sources = TimeSpineSource.build_standard_time_spine_sources(
semantic_manifest_lookup.semantic_manifest
)
self._source_data_sets: List[SemanticModelDataSet] = []
converter = SemanticModelToDataSetConverter(column_association_resolver=self._column_association_resolver)
for semantic_model in sorted(
Expand Down
4 changes: 3 additions & 1 deletion metricflow/plan_conversion/dataflow_to_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ def __init__(
self._semantic_manifest_lookup = semantic_manifest_lookup
self._metric_lookup = semantic_manifest_lookup.metric_lookup
self._semantic_model_lookup = semantic_manifest_lookup.semantic_model_lookup
self._time_spine_sources = TimeSpineSource.create_from_manifest(semantic_manifest_lookup.semantic_manifest)
self._time_spine_sources = TimeSpineSource.build_standard_time_spine_sources(
semantic_manifest_lookup.semantic_manifest
)

@property
def column_association_resolver(self) -> ColumnAssociationResolver: # noqa: D102
Expand Down
6 changes: 3 additions & 3 deletions tests_metricflow/fixtures/table_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ def check_time_spine_source(
The time spine table is defined in a table snapshot YAML file and is restored to the source schema based on that
definition. The definition in the YAML should align with the definition in the time_spine_source fixture.
"""
time_spine_source = TimeSpineSource.create_from_manifest(simple_semantic_manifest_lookup.semantic_manifest)[
TimeGranularity.DAY
]
time_spine_source = TimeSpineSource.build_standard_time_spine_sources(
simple_semantic_manifest_lookup.semantic_manifest
)[TimeGranularity.DAY]
assert (
time_spine_source.schema_name == mf_test_configuration.mf_source_schema
), "The time spine source table should be in the source schema"
Expand Down
6 changes: 3 additions & 3 deletions tests_metricflow/plan_conversion/test_time_spine.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def test_date_spine_date_range( # noqa: D103
simple_semantic_manifest_lookup: SemanticManifestLookup,
create_source_tables: None,
) -> None:
time_spine_source = TimeSpineSource.create_from_manifest(simple_semantic_manifest_lookup.semantic_manifest)[
TimeGranularity.DAY
]
time_spine_source = TimeSpineSource.build_standard_time_spine_sources(
simple_semantic_manifest_lookup.semantic_manifest
)[TimeGranularity.DAY]
range_df = sql_client.query(
textwrap.dedent(
f"""\
Expand Down

0 comments on commit 952cc5a

Please sign in to comment.