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

Cleanup: Rename DefaultGrain to DefaultGranularity where missed #300

Merged
merged 2 commits into from
Jun 28, 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
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity


class SetDefaultGrainRule(ProtocolHint[SemanticManifestTransformRule[PydanticSemanticManifest]]):
class SetDefaultGranularityRule(ProtocolHint[SemanticManifestTransformRule[PydanticSemanticManifest]]):
"""If default_granularity is not set for a metric, set it to DAY if available, else the smallest available grain."""

@override
Expand Down
6 changes: 3 additions & 3 deletions dbt_semantic_interfaces/validations/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ def validate_manifest(semantic_manifest: SemanticManifestT) -> Sequence[Validati
return issues


class DefaultGrainRule(SemanticManifestValidationRule[SemanticManifestT], Generic[SemanticManifestT]):
class DefaultGranularityRule(SemanticManifestValidationRule[SemanticManifestT], Generic[SemanticManifestT]):
"""Checks that default_granularity set for metric is queryable for that metric."""

@staticmethod
Expand Down Expand Up @@ -619,7 +619,7 @@ def _validate_metric(
)

if metric.default_granularity:
min_queryable_granularity = DefaultGrainRule._min_queryable_granularity_for_metric(
min_queryable_granularity = DefaultGranularityRule._min_queryable_granularity_for_metric(
metric=metric, metric_index=metric_index, measure_to_agg_time_dimension=measure_to_agg_time_dimension
)
valid_granularities = [
Expand Down Expand Up @@ -666,7 +666,7 @@ def validate_manifest(semantic_manifest: SemanticManifestT) -> Sequence[Validati

metric_index = {MetricReference(metric.name): metric for metric in semantic_manifest.metrics}
for metric in semantic_manifest.metrics or []:
issues += DefaultGrainRule._validate_metric(
issues += DefaultGranularityRule._validate_metric(
metric=metric,
metric_index=metric_index,
measure_to_agg_time_dimension=measure_to_agg_time_dimension,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "dbt-semantic-interfaces"
version = "0.6.2.dev0"
version = "0.6.2.dev1"
description = 'The shared semantic layer definitions that dbt-core and MetricFlow use'
readme = "README.md"
requires-python = ">=3.8"
Expand Down
4 changes: 2 additions & 2 deletions tests/validations/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
CUMULATIVE_TYPE_PARAMS_SUPPORTED,
ConversionMetricRule,
CumulativeMetricRule,
DefaultGrainRule,
DefaultGranularityRule,
DerivedMetricRule,
WhereFiltersAreParseable,
)
Expand Down Expand Up @@ -722,7 +722,7 @@ def test_default_granularity() -> None:
month_measure_name = "boo"
week_time_dim_name = "ds__week"
month_time_dim_name = "ds__month"
model_validator = SemanticManifestValidator[PydanticSemanticManifest]([DefaultGrainRule()])
model_validator = SemanticManifestValidator[PydanticSemanticManifest]([DefaultGranularityRule()])
validation_results = model_validator.validate_semantic_manifest(
PydanticSemanticManifest(
semantic_models=[
Expand Down
Loading