Skip to content
Draft
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
@@ -0,0 +1,5 @@
from __future__ import annotations

from metricflow_semantics.test_helpers.config_helpers import DirectoryPathAnchor

SG_08_AMBIGUOUS_MULTI_HOP_JOIN = DirectoryPathAnchor()
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
semantic_model:
name: bookings_source

node_relation:
schema_name: $source_schema
alias: bookings_source

defaults:
agg_time_dimension: booking_time

entities:
- name: booking
type: primary
- name: listing
type: foreign

measures:
- name: booking_count
expr: "1"
agg: sum

dimensions:
- name: booking_time
type: time
type_params:
time_granularity: quarter

---
semantic_model:
name: listings_source

node_relation:
schema_name: $source_schema
alias: listings_source

entities:
- name: listing
type: primary
- name: user
type: foreign

---
semantic_model:
name: unique_listings_source

node_relation:
schema_name: $source_schema
alias: listings_source

entities:
- name: unique_listing
type: primary
- name: listing
type: unique
- name: user
type: foreign

---
semantic_model:
name: users_source
description: users_source

node_relation:
schema_name: $source_schema
alias: users_source

entities:
- name: user
type: primary

dimensions:
- name: country_latest
type: categorical

---
metric:
name: bookings
type: simple
type_params:
measure: booking_count


---
saved_query:
name: bookings_saved_query
query_params:
metrics:
- bookings
group_by:
- Dimension('user__country_latest', entity_path=['listing'])
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
project_configuration:
time_spine_table_configurations:
- location: $source_schema.mf_time_spine
column_name: ds
grain: day
time_spines:
- node_relation:
alias: mf_time_spine
schema_name: $source_schema
primary_column:
name: ds
time_granularity: day
- node_relation:
alias: mf_time_spine
schema_name: $source_schema
primary_column:
name: ds_year
time_granularity: year
custom_granularities:
- name: custom_year
31 changes: 31 additions & 0 deletions tests_metricflow/test_sg_error.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from __future__ import annotations

import logging

from metricflow_semantics.test_helpers.manifest_helpers import (
mf_load_manifest_from_yaml_directory,
)
from metricflow_semantics.test_helpers.semantic_manifest_yamls.sg_08_ambiguous_multi_hop_join import (
SG_08_AMBIGUOUS_MULTI_HOP_JOIN,
)

from metricflow.protocols.sql_client import SqlClient
from tests_metricflow.performance.test_profiling_examples import mf_explain_saved_query

logger = logging.getLogger(__name__)


def test_compare_ambiguous_join_path(sql_client: SqlClient) -> None:
"""Compare `explain` output between the legacy resolver and the SG resolver for an ambiguous join path."""
manifest = mf_load_manifest_from_yaml_directory(
SG_08_AMBIGUOUS_MULTI_HOP_JOIN.directory, template_mapping={"source_schema": "dummy_schema"}
)
explain_result = mf_explain_saved_query(
manifest, sql_client, saved_query_names=["bookings_saved_query"], use_semantic_graph=False
)
assert explain_result is not None

explain_result = mf_explain_saved_query(
manifest, sql_client, saved_query_names=["bookings_saved_query"], use_semantic_graph=True
)
assert explain_result is None