From 5ed211e2ce31c330ac9e8cd587b8138db338188e Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Fri, 26 Apr 2024 14:18:59 -0700 Subject: [PATCH] Associated import and method changes in the rest of the codebase. --- .../metricflow_semantics/instances.py | 4 +- .../naming/dunder_scheme.py | 5 +- .../naming/metric_scheme.py | 4 +- .../naming/object_builder_str.py | 7 +- .../test_helpers/snapshot_helpers.py | 3 +- .../semantics/test_linkable_spec_resolver.py | 16 +- .../model/test_semantic_model_container.py | 4 +- .../model/test_where_filter_spec.py | 224 +++++++++++++++--- .../naming/conftest.py | 2 +- .../test_object_builder_naming_scheme.py | 2 +- .../test_available_group_by_items.py | 5 +- .../patterns/test_entity_link_pattern.py | 2 +- .../specs/patterns/test_typed_patterns.py | 2 +- .../tests_metricflow_semantics/test_specs.py | 4 +- .../dataflow/builder/dataflow_plan_builder.py | 16 +- metricflow/dataflow/builder/node_evaluator.py | 7 +- metricflow/dataflow/builder/partitions.py | 4 +- metricflow/dataflow/nodes/filter_elements.py | 2 +- .../source_scan/matching_linkable_specs.py | 2 +- metricflow/engine/metricflow_engine.py | 2 +- metricflow/plan_conversion/dataflow_to_sql.py | 6 +- .../plan_conversion/instance_converters.py | 4 +- metricflow/plan_conversion/node_processor.py | 5 +- metricflow/plan_conversion/spec_transforms.py | 5 +- .../data_warehouse_model_validator.py | 3 +- .../source_scan/test_cm_branch_combiner.py | 3 +- tests_metricflow/examples/test_node_sql.py | 3 +- tests_metricflow/fixtures/setup_fixtures.py | 3 - ...select_columns_with_measures_aggregated.py | 3 +- .../test_dataflow_to_sql_plan.py | 17 +- 30 files changed, 269 insertions(+), 100 deletions(-) diff --git a/metricflow-semantics/metricflow_semantics/instances.py b/metricflow-semantics/metricflow_semantics/instances.py index 99f24e33fa..1ee3cd90f3 100644 --- a/metricflow-semantics/metricflow_semantics/instances.py +++ b/metricflow-semantics/metricflow_semantics/instances.py @@ -11,17 +11,17 @@ from metricflow_semantics.aggregation_properties import AggregationState from metricflow_semantics.specs.column_assoc import ColumnAssociation -from metricflow_semantics.specs.group_by_metric_spec import GroupByMetricSpec from metricflow_semantics.specs.spec_classes import ( DimensionSpec, EntitySpec, + GroupByMetricSpec, InstanceSpec, - InstanceSpecSet, MeasureSpec, MetadataSpec, MetricSpec, TimeDimensionSpec, ) +from metricflow_semantics.specs.spec_set import InstanceSpecSet # Type for the specification used in the instance. SpecT = TypeVar("SpecT", bound=InstanceSpec) diff --git a/metricflow-semantics/metricflow_semantics/naming/dunder_scheme.py b/metricflow-semantics/metricflow_semantics/naming/dunder_scheme.py index 40c43f7a43..53a56acd14 100644 --- a/metricflow-semantics/metricflow_semantics/naming/dunder_scheme.py +++ b/metricflow-semantics/metricflow_semantics/naming/dunder_scheme.py @@ -17,9 +17,8 @@ ) from metricflow_semantics.specs.spec_classes import ( InstanceSpec, - InstanceSpecSet, - InstanceSpecSetTransform, ) +from metricflow_semantics.specs.spec_set import InstanceSpecSet, InstanceSpecSetTransform, group_spec_by_type class DunderNamingScheme(QueryItemNamingScheme): @@ -37,7 +36,7 @@ def date_part_suffix(date_part: DatePart) -> str: @override def input_str(self, instance_spec: InstanceSpec) -> Optional[str]: - spec_set = InstanceSpecSet.from_specs((instance_spec,)) + spec_set = group_spec_by_type(instance_spec) for time_dimension_spec in spec_set.time_dimension_specs: # From existing comment in StructuredLinkableSpecName: diff --git a/metricflow-semantics/metricflow_semantics/naming/metric_scheme.py b/metricflow-semantics/metricflow_semantics/naming/metric_scheme.py index 8fc0cd7c48..92015b4fa7 100644 --- a/metricflow-semantics/metricflow_semantics/naming/metric_scheme.py +++ b/metricflow-semantics/metricflow_semantics/naming/metric_scheme.py @@ -9,8 +9,8 @@ from metricflow_semantics.specs.patterns.metric_pattern import MetricSpecPattern from metricflow_semantics.specs.spec_classes import ( InstanceSpec, - InstanceSpecSet, ) +from metricflow_semantics.specs.spec_set import group_spec_by_type class MetricNamingScheme(QueryItemNamingScheme): @@ -18,7 +18,7 @@ class MetricNamingScheme(QueryItemNamingScheme): @override def input_str(self, instance_spec: InstanceSpec) -> Optional[str]: - spec_set = InstanceSpecSet.from_specs((instance_spec,)) + spec_set = group_spec_by_type(instance_spec) names = tuple(spec.element_name for spec in spec_set.metric_specs) if len(names) != 1: diff --git a/metricflow-semantics/metricflow_semantics/naming/object_builder_str.py b/metricflow-semantics/metricflow_semantics/naming/object_builder_str.py index ce20280268..d1bd3453de 100644 --- a/metricflow-semantics/metricflow_semantics/naming/object_builder_str.py +++ b/metricflow-semantics/metricflow_semantics/naming/object_builder_str.py @@ -14,7 +14,8 @@ from dbt_semantic_interfaces.type_enums.date_part import DatePart from typing_extensions import override -from metricflow_semantics.specs.spec_classes import InstanceSpec, InstanceSpecSet, InstanceSpecSetTransform +from metricflow_semantics.specs.spec_classes import InstanceSpec +from metricflow_semantics.specs.spec_set import InstanceSpecSet, InstanceSpecSetTransform, group_spec_by_type class ObjectBuilderNameConverter: @@ -139,9 +140,7 @@ def transform(self, spec_set: InstanceSpecSet) -> Sequence[str]: @staticmethod def input_str_from_spec(instance_spec: InstanceSpec) -> str: # noqa: D102 - names = ObjectBuilderNameConverter._ObjectBuilderNameTransform().transform( - InstanceSpecSet.from_specs((instance_spec,)) - ) + names = ObjectBuilderNameConverter._ObjectBuilderNameTransform().transform(group_spec_by_type(instance_spec)) if len(names) != 1: raise RuntimeError(f"Did not get exactly 1 name from {instance_spec}. Got {names}") diff --git a/metricflow-semantics/metricflow_semantics/test_helpers/snapshot_helpers.py b/metricflow-semantics/metricflow_semantics/test_helpers/snapshot_helpers.py index 4354c6eed4..32c5fbd178 100644 --- a/metricflow-semantics/metricflow_semantics/test_helpers/snapshot_helpers.py +++ b/metricflow-semantics/metricflow_semantics/test_helpers/snapshot_helpers.py @@ -16,7 +16,8 @@ from metricflow_semantics.mf_logging.pretty_print import mf_pformat from metricflow_semantics.model.semantics.linkable_element_set import LinkableElementSet from metricflow_semantics.naming.object_builder_scheme import ObjectBuilderNamingScheme -from metricflow_semantics.specs.spec_classes import InstanceSpecSet, LinkableSpecSet +from metricflow_semantics.specs.linkable_spec_set import LinkableSpecSet +from metricflow_semantics.specs.spec_set import InstanceSpecSet logger = logging.getLogger(__name__) diff --git a/metricflow-semantics/tests_metricflow_semantics/model/semantics/test_linkable_spec_resolver.py b/metricflow-semantics/tests_metricflow_semantics/model/semantics/test_linkable_spec_resolver.py index a67a0cfaee..bc7c201a1e 100644 --- a/metricflow-semantics/tests_metricflow_semantics/model/semantics/test_linkable_spec_resolver.py +++ b/metricflow-semantics/tests_metricflow_semantics/model/semantics/test_linkable_spec_resolver.py @@ -20,6 +20,7 @@ ValidLinkableSpecResolver, ) from metricflow_semantics.model.semantics.semantic_model_join_evaluator import MAX_JOIN_HOPS +from metricflow_semantics.specs.spec_set import InstanceSpecSet from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration from metricflow_semantics.test_helpers.snapshot_helpers import ( assert_linkable_element_set_snapshot_equal, @@ -193,15 +194,16 @@ def test_linkable_element_set_as_spec_set( double up on the .as_spec_set calls here. Yes, this is lazy. No, I don't care to make another helper to do snapshot comparisons on LinkableSpecSets. """ - linkable_spec_set = simple_model_spec_resolver.get_linkable_element_set_for_measure( - MeasureReference(element_name="listings"), - with_any_of=LinkableElementProperty.all_properties(), - without_any_of=frozenset({}), - ).as_spec_set - + linkable_spec_set = InstanceSpecSet.create_from_specs( + simple_model_spec_resolver.get_linkable_element_set_for_measure( + MeasureReference(element_name="listings"), + with_any_of=LinkableElementProperty.all_properties(), + without_any_of=frozenset({}), + ).specs + ) assert_spec_set_snapshot_equal( request=request, mf_test_configuration=mf_test_configuration, set_id="set0", - spec_set=linkable_spec_set.as_spec_set, + spec_set=linkable_spec_set, ) diff --git a/metricflow-semantics/tests_metricflow_semantics/model/test_semantic_model_container.py b/metricflow-semantics/tests_metricflow_semantics/model/test_semantic_model_container.py index 3eb4aee33f..b0649ba89f 100644 --- a/metricflow-semantics/tests_metricflow_semantics/model/test_semantic_model_container.py +++ b/metricflow-semantics/tests_metricflow_semantics/model/test_semantic_model_container.py @@ -79,7 +79,7 @@ def test_local_linked_elements_for_metric( # noqa: D103 with_any_property=frozenset({LinkableElementProperty.LOCAL_LINKED}), without_any_property=frozenset({LinkableElementProperty.DERIVED_TIME_GRANULARITY}), ) - sorted_specs = sorted(linkable_elements.as_spec_set.as_tuple, key=lambda x: x.qualified_name) + sorted_specs = sorted(linkable_elements.specs, key=lambda x: x.qualified_name) assert_object_snapshot_equal( request=request, mf_test_configuration=mf_test_configuration, @@ -140,7 +140,7 @@ def test_linkable_elements_for_no_metrics_query( LinkableElementProperty.DERIVED_TIME_GRANULARITY, } ) - sorted_specs = sorted(linkable_elements.as_spec_set.as_tuple, key=lambda x: x.qualified_name) + sorted_specs = sorted(linkable_elements.specs, key=lambda x: x.qualified_name) assert_object_snapshot_equal( request=request, mf_test_configuration=mf_test_configuration, diff --git a/metricflow-semantics/tests_metricflow_semantics/model/test_where_filter_spec.py b/metricflow-semantics/tests_metricflow_semantics/model/test_where_filter_spec.py index 6e7d7cc42b..de5bf4b61e 100644 --- a/metricflow-semantics/tests_metricflow_semantics/model/test_where_filter_spec.py +++ b/metricflow-semantics/tests_metricflow_semantics/model/test_where_filter_spec.py @@ -19,10 +19,20 @@ DimensionReference, EntityReference, MetricReference, + SemanticModelReference, TimeDimensionReference, ) +from dbt_semantic_interfaces.type_enums import DimensionType from dbt_semantic_interfaces.type_enums.date_part import DatePart from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity +from metricflow_semantics.model.semantics.linkable_element import ( + ElementPathKey, + LinkableDimension, + LinkableElementType, + LinkableEntity, + LinkableMetric, +) +from metricflow_semantics.model.semantics.linkable_element_set import LinkableElementSet from metricflow_semantics.naming.object_builder_scheme import ObjectBuilderNamingScheme from metricflow_semantics.query.group_by_item.filter_spec_resolution.filter_location import WhereFilterLocation from metricflow_semantics.query.group_by_item.filter_spec_resolution.filter_spec_lookup import ( @@ -34,12 +44,12 @@ from metricflow_semantics.query.group_by_item.resolution_path import MetricFlowQueryResolutionPath from metricflow_semantics.query.issues.issues_base import MetricFlowQueryResolutionIssueSet from metricflow_semantics.specs.column_assoc import ColumnAssociationResolver -from metricflow_semantics.specs.group_by_metric_spec import GroupByMetricSpec +from metricflow_semantics.specs.linkable_spec_set import LinkableSpecSet from metricflow_semantics.specs.spec_classes import ( DimensionSpec, EntitySpec, + GroupByMetricSpec, LinkableInstanceSpec, - LinkableSpecSet, TimeDimensionSpec, WhereFilterSpec, ) @@ -51,7 +61,9 @@ def create_spec_lookup( - call_parameter_set: CallParameterSet, resolved_spec: LinkableInstanceSpec + call_parameter_set: CallParameterSet, + resolved_spec: LinkableInstanceSpec, + resolved_linkable_element_set: LinkableElementSet, ) -> FilterSpecResolutionLookUp: """Create a FilterSpecResolutionLookUp where the call_parameter_set maps to resolved_spec.""" return FilterSpecResolutionLookUp( @@ -63,7 +75,7 @@ def create_spec_lookup( ), filter_location_path=MetricFlowQueryResolutionPath.empty_instance(), where_filter_intersection=create_where_filter_intersection("Dimension('dummy__dimension')"), - resolved_spec=resolved_spec, + resolved_linkable_element_set=resolved_linkable_element_set, issue_set=MetricFlowQueryResolutionIssueSet.empty_instance(), spec_pattern=ObjectBuilderNamingScheme().spec_pattern("Dimension('dummy__dimension')"), object_builder_str="Dimension('dummy__dimension')", @@ -89,6 +101,28 @@ def test_dimension_in_filter( # noqa: D103 dimension_reference=DimensionReference("country_latest"), ), resolved_spec=DimensionSpec(element_name="country_latest", entity_links=(EntityReference("listing"),)), + resolved_linkable_element_set=LinkableElementSet( + path_key_to_linkable_dimensions={ + ElementPathKey( + element_name="country_latest", + element_type=LinkableElementType.DIMENSION, + entity_links=(EntityReference("listing"),), + time_granularity=None, + date_part=None, + ): ( + LinkableDimension( + semantic_model_origin=SemanticModelReference("bookings"), + dimension_type=DimensionType.CATEGORICAL, + element_name="country_latest", + entity_links=(EntityReference("listing"),), + join_path=(), + properties=frozenset(), + time_granularity=None, + date_part=None, + ), + ) + } + ), ), ).create_from_where_filter_intersection( filter_location=EXAMPLE_FILTER_LOCATION, @@ -97,7 +131,7 @@ def test_dimension_in_filter( # noqa: D103 assert len(where_filter_specs) == 1 where_filter_spec = where_filter_specs[0] assert where_filter_spec.where_sql == "listing__country_latest = 'US'" - assert where_filter_spec.linkable_spec_set == LinkableSpecSet( + assert LinkableSpecSet.create_from_specs(where_filter_spec.linkable_specs) == LinkableSpecSet( dimension_specs=( DimensionSpec(element_name="country_latest", entity_links=(EntityReference(element_name="listing"),)), ), @@ -115,29 +149,51 @@ def test_dimension_in_filter_with_grain( # noqa: D103 spec_resolution_lookup=create_spec_lookup( call_parameter_set=TimeDimensionCallParameterSet( entity_path=(EntityReference("listing"),), - time_dimension_reference=TimeDimensionReference("country_latest"), + time_dimension_reference=TimeDimensionReference("created_at"), time_granularity=TimeGranularity.WEEK, ), resolved_spec=TimeDimensionSpec( - element_name="country_latest", + element_name="created_at", entity_links=(EntityReference("listing"),), time_granularity=TimeGranularity.WEEK, ), + resolved_linkable_element_set=LinkableElementSet( + path_key_to_linkable_dimensions={ + ElementPathKey( + element_name="created_at", + element_type=LinkableElementType.TIME_DIMENSION, + entity_links=(EntityReference("listing"),), + time_granularity=TimeGranularity.WEEK, + date_part=None, + ): ( + LinkableDimension( + semantic_model_origin=SemanticModelReference("listings_source"), + dimension_type=DimensionType.TIME, + element_name="created_at", + entity_links=(EntityReference("listing"),), + join_path=(), + properties=frozenset(), + time_granularity=TimeGranularity.WEEK, + date_part=None, + ), + ) + } + ), ), ).create_from_where_filter_intersection( filter_location=EXAMPLE_FILTER_LOCATION, filter_intersection=create_where_filter_intersection( - "{{ Dimension('listing__country_latest').grain('WEEK') }} = 'US'" + "{{ Dimension('listing__created_at').grain('WEEK') }} = 'US'" ), ) assert len(where_filter_specs) == 1 where_filter_spec = where_filter_specs[0] - assert where_filter_spec.where_sql == "listing__country_latest__week = 'US'" - assert where_filter_spec.linkable_spec_set == LinkableSpecSet( + assert where_filter_spec.where_sql == "listing__created_at__week = 'US'" + assert LinkableSpecSet.create_from_specs(where_filter_spec.linkable_specs) == LinkableSpecSet( dimension_specs=(), time_dimension_specs=( TimeDimensionSpec( - element_name="country_latest", + element_name="created_at", entity_links=(EntityReference(element_name="listing"),), time_granularity=TimeGranularity.WEEK, ), @@ -163,6 +219,28 @@ def test_time_dimension_in_filter( # noqa: D103 entity_links=(EntityReference("listing"),), time_granularity=TimeGranularity.MONTH, ), + resolved_linkable_element_set=LinkableElementSet( + path_key_to_linkable_dimensions={ + ElementPathKey( + element_name="created_at", + element_type=LinkableElementType.TIME_DIMENSION, + entity_links=(EntityReference("listing"),), + time_granularity=TimeGranularity.MONTH, + date_part=None, + ): ( + LinkableDimension( + semantic_model_origin=SemanticModelReference("listings_source"), + dimension_type=DimensionType.CATEGORICAL, + element_name="created_at", + entity_links=(EntityReference("listing"),), + join_path=(), + properties=frozenset(), + time_granularity=TimeGranularity.MONTH, + date_part=None, + ), + ) + } + ), ), ).create_from_where_filter_intersection( filter_location=EXAMPLE_FILTER_LOCATION, @@ -173,7 +251,7 @@ def test_time_dimension_in_filter( # noqa: D103 assert len(where_filter_specs) == 1 where_filter_spec = where_filter_specs[0] assert where_filter_spec.where_sql == "listing__created_at__month = '2020-01-01'" - assert where_filter_spec.linkable_spec_set == LinkableSpecSet( + assert LinkableSpecSet.create_from_specs(where_filter_spec.linkable_specs) == LinkableSpecSet( dimension_specs=(), time_dimension_specs=( TimeDimensionSpec( @@ -204,6 +282,28 @@ def test_date_part_in_filter( # noqa: D103 time_granularity=TimeGranularity.DAY, date_part=DatePart.YEAR, ), + resolved_linkable_element_set=LinkableElementSet( + path_key_to_linkable_dimensions={ + ElementPathKey( + element_name="metric_time", + element_type=LinkableElementType.TIME_DIMENSION, + entity_links=(), + time_granularity=TimeGranularity.DAY, + date_part=DatePart.YEAR, + ): ( + LinkableDimension( + semantic_model_origin=SemanticModelReference("bookings"), + dimension_type=DimensionType.TIME, + element_name="metric_time", + entity_links=(), + join_path=(), + properties=frozenset(), + time_granularity=TimeGranularity.DAY, + date_part=DatePart.YEAR, + ), + ) + } + ), ), ).create_from_where_filter_intersection( filter_location=EXAMPLE_FILTER_LOCATION, @@ -214,7 +314,7 @@ def test_date_part_in_filter( # noqa: D103 assert len(where_filter_specs) == 1 where_filter_spec = where_filter_specs[0] assert where_filter_spec.where_sql == "metric_time__extract_year = '2020'" - assert where_filter_spec.linkable_spec_set == LinkableSpecSet( + assert LinkableSpecSet.create_from_specs(where_filter_spec.linkable_specs) == LinkableSpecSet( dimension_specs=(), time_dimension_specs=( TimeDimensionSpec( @@ -248,11 +348,27 @@ def resolved_spec_lookup() -> FilterSpecResolutionLookUp: where_filter_intersection=create_where_filter_intersection( "TimeDimension('metric_time', 'week', 'year')" ), - resolved_spec=TimeDimensionSpec( - element_name="metric_time", - entity_links=(), - time_granularity=TimeGranularity.WEEK, - date_part=DatePart.YEAR, + resolved_linkable_element_set=LinkableElementSet( + path_key_to_linkable_dimensions={ + ElementPathKey( + element_name="metric_time", + element_type=LinkableElementType.TIME_DIMENSION, + entity_links=(), + time_granularity=TimeGranularity.WEEK, + date_part=DatePart.YEAR, + ): ( + LinkableDimension( + semantic_model_origin=SemanticModelReference("bookings"), + dimension_type=DimensionType.TIME, + element_name="metric_time", + entity_links=(), + join_path=(), + properties=frozenset(), + time_granularity=TimeGranularity.WEEK, + date_part=DatePart.YEAR, + ), + ) + } ), spec_pattern=ObjectBuilderNamingScheme().spec_pattern("Dimension('dummy__dimension')"), issue_set=MetricFlowQueryResolutionIssueSet.empty_instance(), @@ -284,7 +400,7 @@ def test_date_part_and_grain_in_filter( # noqa: D103 ).create_from_where_filter(EXAMPLE_FILTER_LOCATION, where_filter) assert where_filter_spec.where_sql == "metric_time__extract_year = '2020'" - assert where_filter_spec.linkable_spec_set == LinkableSpecSet( + assert LinkableSpecSet.create_from_specs(where_filter_spec.linkable_specs) == LinkableSpecSet( dimension_specs=(), time_dimension_specs=( TimeDimensionSpec( @@ -321,7 +437,7 @@ def test_date_part_less_than_grain_in_filter( # noqa: D103 ).create_from_where_filter(EXAMPLE_FILTER_LOCATION, where_filter) assert where_filter_spec.where_sql == "metric_time__extract_day = '2020'" - assert where_filter_spec.linkable_spec_set == LinkableSpecSet( + assert LinkableSpecSet.create_from_specs(where_filter_spec.linkable_specs) == LinkableSpecSet( dimension_specs=(), time_dimension_specs=( TimeDimensionSpec( @@ -352,11 +468,30 @@ def test_entity_in_filter( # noqa: D103 entity_reference=EntityReference("user"), ), resolved_spec=EntitySpec(element_name="user", entity_links=(EntityReference("listing"),)), + resolved_linkable_element_set=LinkableElementSet( + path_key_to_linkable_entities={ + ElementPathKey( + element_name="user", + element_type=LinkableElementType.ENTITY, + entity_links=(EntityReference("listing"),), + time_granularity=TimeGranularity.DAY, + date_part=DatePart.YEAR, + ): ( + LinkableEntity( + semantic_model_origin=SemanticModelReference("bookings"), + element_name="user", + entity_links=(EntityReference("listing"),), + join_path=(), + properties=frozenset(), + ), + ) + } + ), ), ).create_from_where_filter(filter_location=EXAMPLE_FILTER_LOCATION, where_filter=where_filter) assert where_filter_spec.where_sql == "listing__user == 'example_user_id'" - assert where_filter_spec.linkable_spec_set == LinkableSpecSet( + assert LinkableSpecSet.create_from_specs(where_filter_spec.linkable_specs) == LinkableSpecSet( dimension_specs=(), time_dimension_specs=(), entity_specs=(EntitySpec(element_name="user", entity_links=(EntityReference(element_name="listing"),)),), @@ -379,11 +514,30 @@ def test_metric_in_filter( # noqa: D103 metric_reference=MetricReference("bookings"), ), resolved_spec=group_by_metric_spec, + resolved_linkable_element_set=LinkableElementSet( + path_key_to_linkable_metrics={ + ElementPathKey( + element_name="bookings", + element_type=LinkableElementType.METRIC, + entity_links=(EntityReference("listing"),), + time_granularity=None, + date_part=None, + ): ( + LinkableMetric( + join_by_semantic_model=SemanticModelReference("bookings"), + element_name="bookings", + entity_links=(EntityReference("listing"),), + join_path=(), + properties=frozenset(), + ), + ) + } + ), ), ).create_from_where_filter(filter_location=EXAMPLE_FILTER_LOCATION, where_filter=where_filter) assert where_filter_spec.where_sql == "listing__bookings > 2" - assert where_filter_spec.linkable_spec_set == LinkableSpecSet( + assert LinkableSpecSet.create_from_specs(where_filter_spec.linkable_specs) == LinkableSpecSet( dimension_specs=(), time_dimension_specs=(), entity_specs=(), @@ -411,11 +565,27 @@ def get_spec(dimension: str) -> WhereFilterSpec: ), filter_location_path=MetricFlowQueryResolutionPath(()), where_filter_intersection=PydanticWhereFilterIntersection(where_filters=[where_filter]), - resolved_spec=TimeDimensionSpec( - element_name=METRIC_TIME_ELEMENT_NAME, - entity_links=(), - time_granularity=TimeGranularity.WEEK, - date_part=DatePart.YEAR, + resolved_linkable_element_set=LinkableElementSet( + path_key_to_linkable_dimensions={ + ElementPathKey( + element_name=METRIC_TIME_ELEMENT_NAME, + element_type=LinkableElementType.DIMENSION, + entity_links=(EntityReference("listing"),), + time_granularity=TimeGranularity.DAY, + date_part=DatePart.YEAR, + ): ( + LinkableDimension( + semantic_model_origin=SemanticModelReference("bookings"), + dimension_type=DimensionType.TIME, + element_name=METRIC_TIME_ELEMENT_NAME, + entity_links=(), + join_path=(), + properties=frozenset(), + time_granularity=TimeGranularity.WEEK, + date_part=DatePart.YEAR, + ), + ) + } ), spec_pattern=ObjectBuilderNamingScheme().spec_pattern("Dimension('dummy__dimension')"), issue_set=MetricFlowQueryResolutionIssueSet.empty_instance(), diff --git a/metricflow-semantics/tests_metricflow_semantics/naming/conftest.py b/metricflow-semantics/tests_metricflow_semantics/naming/conftest.py index 2f89474db0..3dac120add 100644 --- a/metricflow-semantics/tests_metricflow_semantics/naming/conftest.py +++ b/metricflow-semantics/tests_metricflow_semantics/naming/conftest.py @@ -6,10 +6,10 @@ from dbt_semantic_interfaces.references import EntityReference from dbt_semantic_interfaces.type_enums import TimeGranularity from dbt_semantic_interfaces.type_enums.date_part import DatePart -from metricflow_semantics.specs.group_by_metric_spec import GroupByMetricSpec from metricflow_semantics.specs.spec_classes import ( DimensionSpec, EntitySpec, + GroupByMetricSpec, LinkableInstanceSpec, TimeDimensionSpec, ) diff --git a/metricflow-semantics/tests_metricflow_semantics/naming/test_object_builder_naming_scheme.py b/metricflow-semantics/tests_metricflow_semantics/naming/test_object_builder_naming_scheme.py index 58de22b339..d5abdfcb27 100644 --- a/metricflow-semantics/tests_metricflow_semantics/naming/test_object_builder_naming_scheme.py +++ b/metricflow-semantics/tests_metricflow_semantics/naming/test_object_builder_naming_scheme.py @@ -7,10 +7,10 @@ from dbt_semantic_interfaces.type_enums import TimeGranularity from dbt_semantic_interfaces.type_enums.date_part import DatePart from metricflow_semantics.naming.object_builder_scheme import ObjectBuilderNamingScheme -from metricflow_semantics.specs.group_by_metric_spec import GroupByMetricSpec from metricflow_semantics.specs.spec_classes import ( DimensionSpec, EntitySpec, + GroupByMetricSpec, LinkableInstanceSpec, TimeDimensionSpec, ) diff --git a/metricflow-semantics/tests_metricflow_semantics/query/group_by_item/test_available_group_by_items.py b/metricflow-semantics/tests_metricflow_semantics/query/group_by_item/test_available_group_by_items.py index ffb7af27ff..ad35fa2748 100644 --- a/metricflow-semantics/tests_metricflow_semantics/query/group_by_item/test_available_group_by_items.py +++ b/metricflow-semantics/tests_metricflow_semantics/query/group_by_item/test_available_group_by_items.py @@ -8,7 +8,8 @@ from metricflow_semantics.model.semantic_manifest_lookup import SemanticManifestLookup from metricflow_semantics.query.group_by_item.group_by_item_resolver import GroupByItemResolver from metricflow_semantics.query.group_by_item.resolution_dag.dag import GroupByItemResolutionDag -from metricflow_semantics.specs.spec_classes import LinkableSpecSet +from metricflow_semantics.specs.linkable_spec_set import LinkableSpecSet +from metricflow_semantics.specs.spec_set import group_specs_by_type from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration from metricflow_semantics.test_helpers.snapshot_helpers import assert_linkable_spec_set_snapshot_equal @@ -36,5 +37,5 @@ def test_available_group_by_items( # noqa: D103 request=request, mf_test_configuration=mf_test_configuration, set_id="set0", - spec_set=LinkableSpecSet.from_specs(result.specs), + spec_set=LinkableSpecSet.create_from_spec_set(group_specs_by_type(result.specs)), ) diff --git a/metricflow-semantics/tests_metricflow_semantics/specs/patterns/test_entity_link_pattern.py b/metricflow-semantics/tests_metricflow_semantics/specs/patterns/test_entity_link_pattern.py index af5d270e11..cfb1c4da16 100644 --- a/metricflow-semantics/tests_metricflow_semantics/specs/patterns/test_entity_link_pattern.py +++ b/metricflow-semantics/tests_metricflow_semantics/specs/patterns/test_entity_link_pattern.py @@ -9,7 +9,6 @@ from dbt_semantic_interfaces.references import EntityReference from dbt_semantic_interfaces.type_enums import TimeGranularity from dbt_semantic_interfaces.type_enums.date_part import DatePart -from metricflow_semantics.specs.group_by_metric_spec import GroupByMetricSpec from metricflow_semantics.specs.patterns.entity_link_pattern import ( EntityLinkPattern, EntityLinkPatternParameterSet, @@ -18,6 +17,7 @@ from metricflow_semantics.specs.spec_classes import ( DimensionSpec, EntitySpec, + GroupByMetricSpec, LinkableInstanceSpec, TimeDimensionSpec, ) diff --git a/metricflow-semantics/tests_metricflow_semantics/specs/patterns/test_typed_patterns.py b/metricflow-semantics/tests_metricflow_semantics/specs/patterns/test_typed_patterns.py index 0bdb611568..4c16d8f016 100644 --- a/metricflow-semantics/tests_metricflow_semantics/specs/patterns/test_typed_patterns.py +++ b/metricflow-semantics/tests_metricflow_semantics/specs/patterns/test_typed_patterns.py @@ -18,7 +18,6 @@ ) from dbt_semantic_interfaces.type_enums import TimeGranularity from dbt_semantic_interfaces.type_enums.date_part import DatePart -from metricflow_semantics.specs.group_by_metric_spec import GroupByMetricSpec from metricflow_semantics.specs.patterns.typed_patterns import ( DimensionPattern, EntityPattern, @@ -28,6 +27,7 @@ from metricflow_semantics.specs.spec_classes import ( DimensionSpec, EntitySpec, + GroupByMetricSpec, LinkableInstanceSpec, TimeDimensionSpec, ) diff --git a/metricflow-semantics/tests_metricflow_semantics/test_specs.py b/metricflow-semantics/tests_metricflow_semantics/test_specs.py index eac5e6a951..8413e1c20f 100644 --- a/metricflow-semantics/tests_metricflow_semantics/test_specs.py +++ b/metricflow-semantics/tests_metricflow_semantics/test_specs.py @@ -4,19 +4,19 @@ import pytest from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity -from metricflow_semantics.specs.group_by_metric_spec import GroupByMetricSpec from metricflow_semantics.specs.spec_classes import ( DimensionSpec, EntityReference, EntitySpec, + GroupByMetricSpec, InstanceSpec, - InstanceSpecSet, LinkableInstanceSpec, LinklessEntitySpec, MeasureSpec, MetricSpec, TimeDimensionSpec, ) +from metricflow_semantics.specs.spec_set import InstanceSpecSet @pytest.fixture diff --git a/metricflow/dataflow/builder/dataflow_plan_builder.py b/metricflow/dataflow/builder/dataflow_plan_builder.py index 405f33cf8f..c48457ae52 100644 --- a/metricflow/dataflow/builder/dataflow_plan_builder.py +++ b/metricflow/dataflow/builder/dataflow_plan_builder.py @@ -34,16 +34,15 @@ FilterSpecResolutionLookUp, ) from metricflow_semantics.specs.column_assoc import ColumnAssociationResolver -from metricflow_semantics.specs.group_by_metric_spec import GroupByMetricSpec +from metricflow_semantics.specs.linkable_spec_set import LinkableSpecSet from metricflow_semantics.specs.query_spec import MetricFlowQuerySpec from metricflow_semantics.specs.spec_classes import ( ConstantPropertySpec, CumulativeMeasureDescription, EntitySpec, - InstanceSpecSet, + GroupByMetricSpec, JoinToTimeSpineDescription, LinkableInstanceSpec, - LinkableSpecSet, LinklessEntitySpec, MeasureSpec, MetadataSpec, @@ -54,6 +53,7 @@ TimeDimensionSpec, WhereFilterSpec, ) +from metricflow_semantics.specs.spec_set import InstanceSpecSet, group_specs_by_type from metricflow_semantics.specs.where_filter_transform import WhereSpecFactory from metricflow_semantics.sql.sql_join_type import SqlJoinType @@ -309,7 +309,7 @@ def _build_aggregated_conversion_node( ) filtered_unaggregated_base_node = FilterElementsNode( parent_node=unaggregated_base_measure_node, - include_specs=InstanceSpecSet.from_specs(required_local_specs) + include_specs=group_specs_by_type(required_local_specs) .merge(base_required_linkable_specs.as_spec_set) .dedupe(), ) @@ -1217,9 +1217,11 @@ def __get_required_and_extraneous_linkable_specs( """ linkable_spec_sets_to_merge: List[LinkableSpecSet] = [] for filter_spec in filter_specs: - linkable_spec_sets_to_merge.append(filter_spec.linkable_spec_set) + linkable_spec_sets_to_merge.append(LinkableSpecSet.create_from_specs(filter_spec.linkable_specs)) if non_additive_dimension_spec: - linkable_spec_sets_to_merge.append(non_additive_dimension_spec.linkable_specs) + linkable_spec_sets_to_merge.append( + LinkableSpecSet.create_from_specs(non_additive_dimension_spec.linkable_specs) + ) extraneous_linkable_specs = LinkableSpecSet.merge_iterable(linkable_spec_sets_to_merge).dedupe() required_linkable_specs = queried_linkable_specs.merge(extraneous_linkable_specs).dedupe() @@ -1352,7 +1354,7 @@ def _build_aggregated_measure_from_measure_source_node( filtered_measure_source_node = FilterElementsNode( parent_node=join_to_time_spine_node or time_range_node or measure_recipe.source_node, include_specs=InstanceSpecSet(measure_specs=(measure_spec,)).merge( - InstanceSpecSet.from_specs(measure_recipe.required_local_linkable_specs), + group_specs_by_type(measure_recipe.required_local_linkable_specs), ), ) diff --git a/metricflow/dataflow/builder/node_evaluator.py b/metricflow/dataflow/builder/node_evaluator.py index 858f320059..7e6b36e066 100644 --- a/metricflow/dataflow/builder/node_evaluator.py +++ b/metricflow/dataflow/builder/node_evaluator.py @@ -27,11 +27,10 @@ from metricflow_semantics.model.semantics.semantic_model_join_evaluator import SemanticModelJoinEvaluator from metricflow_semantics.model.semantics.semantic_model_lookup import SemanticModelLookup from metricflow_semantics.specs.spec_classes import ( - InstanceSpecSet, LinkableInstanceSpec, - LinkableSpecSet, LinklessEntitySpec, ) +from metricflow_semantics.specs.spec_set import group_specs_by_type from metricflow_semantics.sql.sql_join_type import SqlJoinType from metricflow.dataflow.builder.node_data_set import DataflowPlanNodeOutputDataSetResolver @@ -120,7 +119,7 @@ def join_description(self) -> JoinDescription: ] ) filtered_node_to_join = FilterElementsNode( - parent_node=self.node_to_join, include_specs=InstanceSpecSet.from_specs(include_specs) + parent_node=self.node_to_join, include_specs=group_specs_by_type(include_specs) ) return JoinDescription( @@ -201,7 +200,7 @@ def _find_joinable_candidate_nodes_that_can_satisfy_linkable_specs( for right_node in self._nodes_available_for_joins: # If right node is time spine source node, use cross join. if right_node == self._time_spine_node: - needed_metric_time_specs = LinkableSpecSet.from_specs(needed_linkable_specs).metric_time_specs + needed_metric_time_specs = group_specs_by_type(needed_linkable_specs).metric_time_specs candidates_for_join.append( JoinLinkableInstancesRecipe( node_to_join=right_node, diff --git a/metricflow/dataflow/builder/partitions.py b/metricflow/dataflow/builder/partitions.py index 0d65e7f76f..510a9fa4ec 100644 --- a/metricflow/dataflow/builder/partitions.py +++ b/metricflow/dataflow/builder/partitions.py @@ -5,12 +5,12 @@ from typing import List, Sequence, Tuple from metricflow_semantics.model.semantics.semantic_model_lookup import SemanticModelLookup +from metricflow_semantics.specs.partition_spec_set import PartitionSpecSet from metricflow_semantics.specs.spec_classes import ( DimensionSpec, - InstanceSpecSet, - PartitionSpecSet, TimeDimensionSpec, ) +from metricflow_semantics.specs.spec_set import InstanceSpecSet from metricflow.dataset.dataset_classes import DataSet diff --git a/metricflow/dataflow/nodes/filter_elements.py b/metricflow/dataflow/nodes/filter_elements.py index 3d110e7e9f..a20ef5c146 100644 --- a/metricflow/dataflow/nodes/filter_elements.py +++ b/metricflow/dataflow/nodes/filter_elements.py @@ -5,7 +5,7 @@ from metricflow_semantics.dag.id_prefix import IdPrefix, StaticIdPrefix from metricflow_semantics.dag.mf_dag import DisplayedProperty from metricflow_semantics.mf_logging.pretty_print import mf_pformat -from metricflow_semantics.specs.spec_classes import InstanceSpecSet +from metricflow_semantics.specs.spec_set import InstanceSpecSet from metricflow_semantics.visitor import VisitorOutputT from metricflow.dataflow.dataflow_plan import BaseOutput, DataflowPlanNode, DataflowPlanNodeVisitor diff --git a/metricflow/dataflow/optimizer/source_scan/matching_linkable_specs.py b/metricflow/dataflow/optimizer/source_scan/matching_linkable_specs.py index e5b3c7da47..3aedbedf71 100644 --- a/metricflow/dataflow/optimizer/source_scan/matching_linkable_specs.py +++ b/metricflow/dataflow/optimizer/source_scan/matching_linkable_specs.py @@ -1,6 +1,6 @@ from __future__ import annotations -from metricflow_semantics.specs.spec_classes import InstanceSpecSet, InstanceSpecSetTransform +from metricflow_semantics.specs.spec_set import InstanceSpecSet, InstanceSpecSetTransform class MatchingLinkableSpecsTransform(InstanceSpecSetTransform[bool]): diff --git a/metricflow/engine/metricflow_engine.py b/metricflow/engine/metricflow_engine.py index 915a17ec81..60612b8d8a 100644 --- a/metricflow/engine/metricflow_engine.py +++ b/metricflow/engine/metricflow_engine.py @@ -32,7 +32,7 @@ from metricflow_semantics.specs.dunder_column_association_resolver import DunderColumnAssociationResolver from metricflow_semantics.specs.query_param_implementations import SavedQueryParameter from metricflow_semantics.specs.query_spec import MetricFlowQuerySpec -from metricflow_semantics.specs.spec_classes import InstanceSpecSet +from metricflow_semantics.specs.spec_set import InstanceSpecSet from metricflow_semantics.time.time_source import TimeSource from metricflow.dataflow.builder.dataflow_plan_builder import DataflowPlanBuilder diff --git a/metricflow/plan_conversion/dataflow_to_sql.py b/metricflow/plan_conversion/dataflow_to_sql.py index c8278444d0..772dae2ea4 100644 --- a/metricflow/plan_conversion/dataflow_to_sql.py +++ b/metricflow/plan_conversion/dataflow_to_sql.py @@ -30,14 +30,14 @@ ColumnAssociationResolver, SingleColumnCorrelationKey, ) -from metricflow_semantics.specs.group_by_metric_spec import GroupByMetricSpec from metricflow_semantics.specs.spec_classes import ( - InstanceSpecSet, + GroupByMetricSpec, MeasureSpec, MetadataSpec, MetricSpec, TimeDimensionSpec, ) +from metricflow_semantics.specs.spec_set import InstanceSpecSet from metricflow_semantics.sql.sql_join_type import SqlJoinType from metricflow_semantics.time.time_constants import ISO8601_PYTHON_FORMAT @@ -874,7 +874,7 @@ def visit_where_constraint_node(self, node: WhereConstraintNode) -> SqlDataSet: column_associations_in_where_sql: Sequence[ColumnAssociation] = CreateColumnAssociations( column_association_resolver=self._column_association_resolver - ).transform(spec_set=node.where.linkable_spec_set.as_spec_set) + ).transform(spec_set=InstanceSpecSet.create_from_specs(node.where.linkable_specs)) return SqlDataSet( instance_set=output_instance_set, diff --git a/metricflow/plan_conversion/instance_converters.py b/metricflow/plan_conversion/instance_converters.py index 51987abe0f..39fab0d316 100644 --- a/metricflow/plan_conversion/instance_converters.py +++ b/metricflow/plan_conversion/instance_converters.py @@ -29,19 +29,19 @@ from metricflow_semantics.model.semantics.metric_lookup import MetricLookup from metricflow_semantics.model.semantics.semantic_model_lookup import SemanticModelLookup from metricflow_semantics.specs.column_assoc import ColumnAssociationResolver -from metricflow_semantics.specs.group_by_metric_spec import GroupByMetricSpec from metricflow_semantics.specs.spec_classes import ( DimensionSpec, EntityReference, EntitySpec, + GroupByMetricSpec, InstanceSpec, - InstanceSpecSet, LinkableInstanceSpec, LinklessEntitySpec, MeasureSpec, MetricInputMeasureSpec, TimeDimensionSpec, ) +from metricflow_semantics.specs.spec_set import InstanceSpecSet from more_itertools import bucket from metricflow.dataflow.nodes.join_to_base import ValidityWindowJoinDescription diff --git a/metricflow/plan_conversion/node_processor.py b/metricflow/plan_conversion/node_processor.py index f58756542d..8499ca47b7 100644 --- a/metricflow/plan_conversion/node_processor.py +++ b/metricflow/plan_conversion/node_processor.py @@ -9,7 +9,8 @@ from metricflow_semantics.mf_logging.pretty_print import mf_pformat from metricflow_semantics.model.semantics.semantic_model_join_evaluator import MAX_JOIN_HOPS from metricflow_semantics.model.semantics.semantic_model_lookup import SemanticModelLookup -from metricflow_semantics.specs.spec_classes import InstanceSpecSet, LinkableInstanceSpec, LinklessEntitySpec +from metricflow_semantics.specs.spec_classes import LinkableInstanceSpec, LinklessEntitySpec +from metricflow_semantics.specs.spec_set import group_specs_by_type from metricflow_semantics.specs.spec_set_transforms import ToElementNameSet from metricflow_semantics.sql.sql_join_type import SqlJoinType @@ -223,7 +224,7 @@ def _get_candidates_nodes_for_multi_hop( specs = data_set_of_second_node_that_can_be_joined.instance_set.spec_set filtered_joinable_node = FilterElementsNode( parent_node=second_node_that_could_be_joined, - include_specs=InstanceSpecSet.from_specs( + include_specs=group_specs_by_type( specs.dimension_specs + specs.entity_specs + specs.time_dimension_specs ), ) diff --git a/metricflow/plan_conversion/spec_transforms.py b/metricflow/plan_conversion/spec_transforms.py index 9cdab81984..b2e86ac0c7 100644 --- a/metricflow/plan_conversion/spec_transforms.py +++ b/metricflow/plan_conversion/spec_transforms.py @@ -3,10 +3,7 @@ from typing import List, Sequence from metricflow_semantics.specs.column_assoc import ColumnAssociation, ColumnAssociationResolver -from metricflow_semantics.specs.spec_classes import ( - InstanceSpecSet, - InstanceSpecSetTransform, -) +from metricflow_semantics.specs.spec_set import InstanceSpecSet, InstanceSpecSetTransform from metricflow.plan_conversion.select_column_gen import SelectColumnSet from metricflow.plan_conversion.sql_expression_builders import make_coalesced_expr diff --git a/metricflow/validation/data_warehouse_model_validator.py b/metricflow/validation/data_warehouse_model_validator.py index 7d43e34e11..99a35829c2 100644 --- a/metricflow/validation/data_warehouse_model_validator.py +++ b/metricflow/validation/data_warehouse_model_validator.py @@ -30,7 +30,8 @@ ) from metricflow_semantics.model.semantic_manifest_lookup import SemanticManifestLookup from metricflow_semantics.specs.dunder_column_association_resolver import DunderColumnAssociationResolver -from metricflow_semantics.specs.spec_classes import InstanceSpecSet, LinkableInstanceSpec, MeasureSpec +from metricflow_semantics.specs.spec_classes import LinkableInstanceSpec, MeasureSpec +from metricflow_semantics.specs.spec_set import InstanceSpecSet from metricflow_semantics.sql.sql_bind_parameters import SqlBindParameters from metricflow.dataflow.builder.node_data_set import DataflowPlanNodeOutputDataSetResolver diff --git a/tests_metricflow/dataflow/optimizer/source_scan/test_cm_branch_combiner.py b/tests_metricflow/dataflow/optimizer/source_scan/test_cm_branch_combiner.py index 56aca18e6c..88f959e50c 100644 --- a/tests_metricflow/dataflow/optimizer/source_scan/test_cm_branch_combiner.py +++ b/tests_metricflow/dataflow/optimizer/source_scan/test_cm_branch_combiner.py @@ -6,7 +6,8 @@ from _pytest.fixtures import FixtureRequest from metricflow_semantics.dag.id_prefix import StaticIdPrefix from metricflow_semantics.dag.mf_dag import DagId -from metricflow_semantics.specs.spec_classes import InstanceSpecSet, MeasureSpec +from metricflow_semantics.specs.spec_classes import MeasureSpec +from metricflow_semantics.specs.spec_set import InstanceSpecSet from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration from metricflow_semantics.test_helpers.snapshot_helpers import assert_plan_snapshot_text_equal diff --git a/tests_metricflow/examples/test_node_sql.py b/tests_metricflow/examples/test_node_sql.py index cd6e517563..d3c96fffc6 100644 --- a/tests_metricflow/examples/test_node_sql.py +++ b/tests_metricflow/examples/test_node_sql.py @@ -8,7 +8,8 @@ from metricflow_semantics.mf_logging.pretty_print import mf_pformat from metricflow_semantics.model.semantic_manifest_lookup import SemanticManifestLookup from metricflow_semantics.specs.dunder_column_association_resolver import DunderColumnAssociationResolver -from metricflow_semantics.specs.spec_classes import InstanceSpecSet, TimeDimensionReference, TimeDimensionSpec +from metricflow_semantics.specs.spec_classes import TimeDimensionReference, TimeDimensionSpec +from metricflow_semantics.specs.spec_set import InstanceSpecSet from metricflow.dataflow.builder.node_data_set import DataflowPlanNodeOutputDataSetResolver from metricflow.dataflow.nodes.filter_elements import FilterElementsNode diff --git a/tests_metricflow/fixtures/setup_fixtures.py b/tests_metricflow/fixtures/setup_fixtures.py index 3d441d9c83..c346d2c821 100644 --- a/tests_metricflow/fixtures/setup_fixtures.py +++ b/tests_metricflow/fixtures/setup_fixtures.py @@ -24,9 +24,6 @@ logger = logging.getLogger(__name__) -# from metricflow.test.time.configurable_time_source import ConfigurableTimeSource - - DISPLAY_GRAPHS_CLI_FLAG = "--display-graphs" USE_PERSISTENT_SOURCE_SCHEMA_CLI_FLAG = "--use-persistent-source-schema" diff --git a/tests_metricflow/plan_conversion/instance_converters/test_create_select_columns_with_measures_aggregated.py b/tests_metricflow/plan_conversion/instance_converters/test_create_select_columns_with_measures_aggregated.py index fbd9f7eb10..c07ade0bb6 100644 --- a/tests_metricflow/plan_conversion/instance_converters/test_create_select_columns_with_measures_aggregated.py +++ b/tests_metricflow/plan_conversion/instance_converters/test_create_select_columns_with_measures_aggregated.py @@ -5,7 +5,8 @@ from metricflow_semantics.instances import InstanceSet from metricflow_semantics.model.semantic_manifest_lookup import SemanticManifestLookup from metricflow_semantics.specs.dunder_column_association_resolver import DunderColumnAssociationResolver -from metricflow_semantics.specs.spec_classes import InstanceSpecSet, MeasureSpec, MetricInputMeasureSpec +from metricflow_semantics.specs.spec_classes import MeasureSpec, MetricInputMeasureSpec +from metricflow_semantics.specs.spec_set import InstanceSpecSet from metricflow.plan_conversion.instance_converters import ( CreateSelectColumnsWithMeasuresAggregated, diff --git a/tests_metricflow/plan_conversion/test_dataflow_to_sql_plan.py b/tests_metricflow/plan_conversion/test_dataflow_to_sql_plan.py index 73cee1d92c..5c1e4c51bf 100644 --- a/tests_metricflow/plan_conversion/test_dataflow_to_sql_plan.py +++ b/tests_metricflow/plan_conversion/test_dataflow_to_sql_plan.py @@ -16,8 +16,6 @@ from metricflow_semantics.specs.query_spec import MetricFlowQuerySpec from metricflow_semantics.specs.spec_classes import ( DimensionSpec, - InstanceSpecSet, - LinkableSpecSet, LinklessEntitySpec, MeasureSpec, MetricInputMeasureSpec, @@ -27,6 +25,7 @@ TimeDimensionSpec, WhereFilterSpec, ) +from metricflow_semantics.specs.spec_set import InstanceSpecSet from metricflow_semantics.sql.sql_bind_parameters import SqlBindParameters from metricflow_semantics.sql.sql_join_type import SqlJoinType from metricflow_semantics.test_helpers.config_helpers import MetricFlowTestConfiguration @@ -192,14 +191,12 @@ def test_filter_with_where_constraint_node( where_constraint=WhereFilterSpec( where_sql="booking__ds__day = '2020-01-01'", bind_parameters=SqlBindParameters(), - linkable_spec_set=LinkableSpecSet( - time_dimension_specs=( - TimeDimensionSpec( - element_name="ds", - entity_links=(EntityReference(element_name="booking"),), - time_granularity=TimeGranularity.DAY, - ), - ) + linkable_specs=( + TimeDimensionSpec( + element_name="ds", + entity_links=(EntityReference(element_name="booking"),), + time_granularity=TimeGranularity.DAY, + ), ), ), )