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

Switch from checked_agg_time_dimension to checked_agg_time_dimension_for_measure #113

Merged
merged 10 commits into from
Jul 12, 2023

Conversation

QMalcolm
Copy link
Collaborator

Resolves #None

Description

The agg_time_dimension of a measure is Optional, but we were only have treating it as such. @tlento's change in #101 was the first wave of this change. This proliferates the change fully thought DSI.

Checklist

@cla-bot cla-bot bot added the cla:yes label Jul 11, 2023
@QMalcolm QMalcolm requested a review from plypaul July 11, 2023 23:27
QMalcolm added 9 commits July 11, 2023 16:29
…col and implementation

Since we're removing `checked_agg_time_dimension` from `Measures`, it makes
it easier for others to transition if we provide a new method at the
appropriate level instead of requiring them to implement it themselves.
…ion_for_measure`

Note: This rule seems very similar to `MeasuresNonAdditiveDimensionRule` maybe we can
deduplicate these slightly in the future.
It essentialy the same as the `AggregationTimeDimensionRule`, but only
giving a warning.
We no longer require the `agg_time_dimension` of a `Measure` be set,
thus this rule is obsolete
The `agg_time_dimension` is no longer required for measures. It's only
required if the measure's parent `SemanticModel` doesn't have a
`defaults.agg_time_dimension` set
…_dimension` not being required on measures
@QMalcolm QMalcolm force-pushed the qmalcolm--fix-agg-time-dimension branch from 9ad1ee9 to 88de482 Compare July 11, 2023 23:29
@QMalcolm QMalcolm changed the title Qmalcolm fix agg time dimension Switch from checked_agg_time_dimension to checked_agg_time_dimension_for_measure Jul 11, 2023
Copy link
Contributor

@plypaul plypaul left a comment

Choose a reason for hiding this comment

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

LGTM aside from comment.

@@ -167,3 +169,15 @@ def get_entity(self, entity_reference: LinkableElementReference) -> PydanticEnti
return entity

raise ValueError(f"No entity with name ({entity_reference}) in semantic_model with name ({self.name})")

def checked_agg_time_dimension_for_measure(self, measure: Measure): # noqa: D
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of the measure object, using a measure reference seems more robust since this only applies to measures from this semantic model.

Copy link
Collaborator Author

@QMalcolm QMalcolm Jul 12, 2023

Choose a reason for hiding this comment

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

Agreed. Doing so adds the guarantee that the measure can be found on the semantic model, which is nice. It's unfortunate that everywhere where we currently call checked_agg_time_dimension in MetricFlow and dbt-semantic-interfaces (and will be now calling checked_agg_time_dimension_for_measure) we already have the full measure object. So we'll be invoking another list iteration even though we don't have to. If that ever becomes an actual issue though, we'll know where to look.

…asureReference`

Previously we were taking in a fully realized `Measure` object as a parameter
to `checked_agg_time_dimension_for_measure`.  By switching to taking in only
a `MeasureReference` the function now guarantees that the referenced `Measure`
belongs to the `SemanticModel`. This has the unfortunate side affect of preforming
an additional list based lookup, but if this ever becomes an issue, we'll know
what we can do.
@QMalcolm QMalcolm merged commit 5fdb2e3 into main Jul 12, 2023
@QMalcolm QMalcolm deleted the qmalcolm--fix-agg-time-dimension branch July 12, 2023 14:47
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