Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Methods to look up agg_time_dimensions #995

Merged
merged 4 commits into from
Jan 25, 2024
Merged

Conversation

courtneyholcomb
Copy link
Contributor

@courtneyholcomb courtneyholcomb commented Jan 25, 2024

Description

Adds some methods that will be used to enable querying with agg_time_dimension instead of metric_time.
MetricLookup.get_valid_agg_time_dimensions_for_metric() will be used in validations, while SemanticModelLookup.get_agg_time_dimension_specs_for_measure() will be used in query building.

@cla-bot cla-bot bot added the cla:yes label Jan 25, 2024
Copy link

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

linkable_element_sets_to_merge.append(
ValidLinkableSpecResolver._get_elements_in_semantic_model(semantic_model)
)
linkable_element_sets_to_merge.append(self._get_elements_in_semantic_model(semantic_model))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in this file were made to avoid a circular import.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense!

@courtneyholcomb courtneyholcomb changed the title Methods to look up agg_time_dimensions Methods to look up agg_time_dimensions Jan 25, 2024
@courtneyholcomb courtneyholcomb marked this pull request as ready for review January 25, 2024 02:42
@courtneyholcomb courtneyholcomb requested review from tlento, plypaul and WilliamDee and removed request for tlento and plypaul January 25, 2024 02:43
Copy link
Contributor

@tlento tlento left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable! Can we add some test cases for the new methods before merge? The tests for these classes seem to live in metricflow/test/model/test_semantic_model_container.py so we should be able to add a few cases pretty easily.

linkable_element_sets_to_merge.append(
ValidLinkableSpecResolver._get_elements_in_semantic_model(semantic_model)
)
linkable_element_sets_to_merge.append(self._get_elements_in_semantic_model(semantic_model))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense!

@@ -300,14 +301,12 @@ def _resolved_primary_entity(semantic_model: SemanticModel) -> Optional[EntityRe
)

# This should be caught by the validation, but adding a sanity check.
assert len(entities_with_type_primary) <= 1, f"Found >1 primary entity in {semantic_model}"
assert len(entities_with_type_primary) <= 1, f"Found > 1 primary entity in {semantic_model}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spaaaaaaaaace!

entity_link = self.resolved_primary_entity(semantic_model)
assert (
entity_link is not None
), f"Expected semantic model {semantic_model} to have a primary entity since is contains dimensions, but found none."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, this is implicit, right? We know it contains a measure, which means it must have an agg_time_dimension, which means it has at least a time dimension.

Maybe update the message to to have a primary entity since it has a measure requiring an agg_time_dimension?

Regardless, micro-nit - it not is.

@courtneyholcomb courtneyholcomb enabled auto-merge (squash) January 25, 2024 23:08
@courtneyholcomb courtneyholcomb merged commit e628fb1 into main Jan 25, 2024
9 checks passed
@courtneyholcomb courtneyholcomb deleted the court/get-agg-time-dims branch January 25, 2024 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants