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

Bug fix: case-sensitive validation warning for filter granularity #352

Merged
merged 3 commits into from
Oct 1, 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
4 changes: 2 additions & 2 deletions dbt_semantic_interfaces/validations/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,13 @@ def _validate_time_granularity_names(
issues: List[ValidationIssue] = []

valid_granularity_names = [
standard_granularity.name for standard_granularity in TimeGranularity
standard_granularity.value for standard_granularity in TimeGranularity
] + custom_granularity_names
for _, parameter_set in filter_expression_parameter_sets:
for time_dim_call_parameter_set in parameter_set.time_dimension_call_parameter_sets:
if not time_dim_call_parameter_set.time_granularity_name:
continue
if time_dim_call_parameter_set.time_granularity_name not in valid_granularity_names:
if time_dim_call_parameter_set.time_granularity_name.lower() not in valid_granularity_names:
issues.append(
ValidationWarning(
context=context,
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.7.2"
version = "0.7.3"
description = 'The shared semantic layer definitions that dbt-core and MetricFlow use'
readme = "README.md"
requires-python = ">=3.8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ saved_query:
metrics:
- listings
group_by:
- TimeDimension('metric_time', 'DAY')
- TimeDimension('metric_time', 'day')
where:
- "{{ Metric('bookings', group_by=['listing', 'metric_time']) }} > 5"
order_by:
- Metric('listings').descending(True)
- TimeDimension('metric_time', 'DAY')
- TimeDimension('metric_time', 'day')
limit: 10

exports:
Expand Down
2 changes: 2 additions & 0 deletions tests/parsing/test_object_builder_item_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def test_valid_object_builder_items() -> None: # noqa: D
"Entity('listing__created_at', entity_path=['host'])",
"Metric('bookings', group_by=['listing__created_at'])",
"TimeDimension('metric_time', time_granularity_name='martian_year')",
"TimeDimension('metric_time', time_granularity_name='month')",
"TimeDimension('metric_time', time_granularity_name='MONTH')",
)
for valid_item in valid_items:
logger.info(f"Checking {valid_item=}")
Expand Down
6 changes: 5 additions & 1 deletion tests/validations/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,11 @@ def test_where_filter_validations_invalid_granularity( # noqa: D
assert metric.type_params.metrics is not None
input_metric = metric.type_params.metrics[0]
input_metric.filter = PydanticWhereFilterIntersection(
where_filters=[PydanticWhereFilter(where_sql_template="{{ TimeDimension('metric_time', 'cool') }}")]
where_filters=[
PydanticWhereFilter(where_sql_template="{{ TimeDimension('metric_time', 'cool') }}"),
PydanticWhereFilter(where_sql_template="{{ TimeDimension('metric_time', 'month') }}"),
PydanticWhereFilter(where_sql_template="{{ TimeDimension('metric_time', 'MONTH') }}"),
]
)
validator = SemanticManifestValidator[PydanticSemanticManifest]([WhereFiltersAreParseable()])
issues = validator.validate_semantic_manifest(manifest)
Expand Down
Loading