Skip to content

Commit

Permalink
Use time spines to determine metric_time grain in no-metric queries
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed Jul 26, 2024
1 parent f399e6d commit 9cc7d44
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from metricflow_semantics.model.semantics.linkable_element_set import LinkableElementSet
from metricflow_semantics.model.semantics.semantic_model_join_evaluator import SemanticModelJoinEvaluator
from metricflow_semantics.specs.time_dimension_spec import DEFAULT_TIME_GRANULARITY
from metricflow_semantics.time.time_spine_source import TimeSpineSource

if TYPE_CHECKING:
from metricflow_semantics.model.semantics.semantic_model_lookup import SemanticModelLookup
Expand Down Expand Up @@ -124,6 +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)

assert max_entity_links >= 0
self._max_entity_links = max_entity_links
Expand Down Expand Up @@ -464,7 +466,8 @@ def _get_metric_time_elements(self, measure_reference: Optional[MeasureReference
time_dimension_reference=measure_agg_time_dimension_reference,
)
else:
defined_granularity = DEFAULT_TIME_GRANULARITY
# If querying metric_time without metrics, will query from time spines.
defined_granularity = min(self._time_spine_sources.keys())

# It's possible to aggregate measures to coarser time granularities (except with cumulative metrics).
possible_metric_time_granularities = tuple(
Expand Down

0 comments on commit 9cc7d44

Please sign in to comment.