Skip to content

Commit

Permalink
Remove SetMetricTimeGranularityRule (#311)
Browse files Browse the repository at this point in the history
### Description
Per discussion, removing this rule in favor of putting this logic in the
group by resolution DAG instead.

### Checklist

- [x] I have read [the contributing
guide](https://github.com/dbt-labs/dbt-semantic-interfaces/blob/main/CONTRIBUTING.md)
and understand what's expected of me
- [x] I have signed the
[CLA](https://docs.getdbt.com/docs/contributor-license-agreements)
- [x] This PR includes tests, or tests are not required/relevant for
this PR
- [ ] I have run `changie new` to [create a changelog
entry](https://github.com/dbt-labs/dbt-semantic-interfaces/blob/main/CONTRIBUTING.md#adding-a-changelog-entry)
  • Loading branch information
courtneyholcomb authored Jul 12, 2024
1 parent 4d5de68 commit 2e4004a
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 114 deletions.
75 changes: 0 additions & 75 deletions dbt_semantic_interfaces/transformations/metric_time_granularity.py

This file was deleted.

4 changes: 0 additions & 4 deletions dbt_semantic_interfaces/transformations/pydantic_rule_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
from dbt_semantic_interfaces.transformations.cumulative_type_params import (
SetCumulativeTypeParamsRule,
)
from dbt_semantic_interfaces.transformations.metric_time_granularity import (
SetMetricTimeGranularityRule,
)
from dbt_semantic_interfaces.transformations.names import LowerCaseNamesRule
from dbt_semantic_interfaces.transformations.proxy_measure import CreateProxyMeasureRule
from dbt_semantic_interfaces.transformations.rule_set import (
Expand Down Expand Up @@ -57,7 +54,6 @@ def secondary_rules(self) -> Sequence[SemanticManifestTransformRule[PydanticSema
ConvertMedianToPercentileRule(),
AddInputMetricMeasuresRule(),
SetCumulativeTypeParamsRule(),
SetMetricTimeGranularityRule(),
)

@property
Expand Down
35 changes: 0 additions & 35 deletions tests/transformations/test_configurable_transform_rules.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
from typing import Dict

from dbt_semantic_interfaces.implementations.semantic_manifest import (
PydanticSemanticManifest,
)
from dbt_semantic_interfaces.transformations.metric_time_granularity import (
SetMetricTimeGranularityRule,
)
from dbt_semantic_interfaces.transformations.semantic_manifest_transformer import (
PydanticSemanticManifestTransformer,
)
from dbt_semantic_interfaces.transformations.transform_rule import (
SemanticManifestTransformRule,
)
from dbt_semantic_interfaces.type_enums import TimeGranularity


class SliceNamesRule(SemanticManifestTransformRule):
Expand All @@ -38,32 +32,3 @@ def test_can_configure_model_transform_rules( # noqa: D
rules = [SliceNamesRule()]
transformed_model = PydanticSemanticManifestTransformer.transform(pre_model, ordered_rule_sequences=(rules,))
assert all(len(x.name) == 3 for x in transformed_model.semantic_models)


def test_set_time_granularity_rule( # noqa: D
simple_semantic_manifest__with_primary_transforms: PydanticSemanticManifest,
) -> None:
pre_model = simple_semantic_manifest__with_primary_transforms

metric_exists_without_time_granularity = False
configured_default_granularities: Dict[str, TimeGranularity] = {}
for metric in pre_model.metrics:
if metric.time_granularity:
configured_default_granularities[metric.name] = metric.time_granularity
metric_exists_without_time_granularity = True

assert (
pre_model.metrics and metric_exists_without_time_granularity
), "If there are no metrics without a configured time_granularity, this tests nothing."

rules = [SetMetricTimeGranularityRule()]
transformed_model = PydanticSemanticManifestTransformer.transform(pre_model, ordered_rule_sequences=(rules,))

for metric in transformed_model.metrics:
assert metric.time_granularity, f"No time_granularity set in transformation for metric '{metric.name}'"
if metric.name in configured_default_granularities:
assert (
metric.time_granularity == configured_default_granularities[metric.name]
), f"Time granularity was unexpected changed during transformation for metric '{metric.name}"
if metric.name == "monthly_times_yearly_bookings":
assert metric.time_granularity == TimeGranularity.YEAR

0 comments on commit 2e4004a

Please sign in to comment.