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

Remove SetMetricTimeGranularityRule #311

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

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
Loading