-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update
MetricFlowQueryResolution.queried_semantic_models
for Conver…
…sion Metrics (#1204) ### Description I noticed that the `queried_semantic_models` field was not correct for conversion metrics and also for queries without any group-by-items. This PR addresses those cases. <!--- Before requesting review, please make sure you have: 1. read [the contributing guide](https://github.com/dbt-labs/metricflow/blob/main/CONTRIBUTING.md), 2. signed the [CLA](https://docs.getdbt.com/docs/contributor-license-agreements) 3. run `changie new` to [create a changelog entry](https://github.com/dbt-labs/metricflow/blob/main/CONTRIBUTING.md#adding-a-changelog-entry) -->
- Loading branch information
Showing
8 changed files
with
198 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
metricflow-semantics/tests_metricflow_semantics/query/test_conversion_metrics.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from __future__ import annotations | ||
|
||
import pytest | ||
from _pytest.fixtures import FixtureRequest | ||
from dbt_semantic_interfaces.implementations.semantic_manifest import PydanticSemanticManifest | ||
from metricflow_semantics.model.semantic_manifest_lookup import SemanticManifestLookup | ||
from metricflow_semantics.query.query_parser import MetricFlowQueryParser | ||
from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration | ||
from metricflow_semantics.test_helpers.snapshot_helpers import assert_object_snapshot_equal | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def query_parser(simple_semantic_manifest: PydanticSemanticManifest) -> MetricFlowQueryParser: # noqa: D103 | ||
return MetricFlowQueryParser(SemanticManifestLookup(simple_semantic_manifest)) | ||
|
||
|
||
def test_conversion_rate_with_constant_properties( # noqa: D103 | ||
request: FixtureRequest, | ||
mf_test_configuration: MetricFlowTestConfiguration, | ||
query_parser: MetricFlowQueryParser, | ||
) -> None: | ||
result = query_parser.parse_and_validate_query( | ||
metric_names=("visit_buy_conversion_rate_by_session",), | ||
group_by_names=("visit__referrer_id", "user__home_state_latest", "metric_time"), | ||
) | ||
|
||
assert_object_snapshot_equal( | ||
request=request, | ||
mf_test_configuration=mf_test_configuration, | ||
obj=result, | ||
) |
24 changes: 24 additions & 0 deletions
24
...ion_metrics.py/ParseQueryResult/test_conversion_rate_with_constant_properties__result.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
ParseQueryResult( | ||
query_spec=MetricFlowQuerySpec( | ||
metric_specs=(MetricSpec(element_name='visit_buy_conversion_rate_by_session'),), | ||
dimension_specs=( | ||
DimensionSpec( | ||
element_name='referrer_id', | ||
entity_links=(EntityReference(element_name='visit'),), | ||
), | ||
DimensionSpec( | ||
element_name='home_state_latest', | ||
entity_links=(EntityReference(element_name='user'),), | ||
), | ||
), | ||
time_dimension_specs=(TimeDimensionSpec(element_name='metric_time', time_granularity=DAY),), | ||
filter_intersection=PydanticWhereFilterIntersection(), | ||
filter_spec_resolution_lookup=FilterSpecResolutionLookUp(), | ||
min_max_only=False, | ||
), | ||
queried_semantic_models=( | ||
SemanticModelReference(semantic_model_name='buys_source'), | ||
SemanticModelReference(semantic_model_name='users_latest'), | ||
SemanticModelReference(semantic_model_name='visits_source'), | ||
), | ||
) |