From ccaf493ead61ccef810110f0f2d61e37bbb061d7 Mon Sep 17 00:00:00 2001 From: Paul Yang Date: Fri, 5 Jan 2024 01:10:03 -0800 Subject: [PATCH] Cleanup MetricFlowQueryParser initializer signature. --- metricflow/engine/metricflow_engine.py | 3 +-- metricflow/query/query_parser.py | 6 ++---- metricflow/test/fixtures/dataflow_fixtures.py | 7 ++----- metricflow/test/fixtures/model_fixtures.py | 3 +-- metricflow/test/query/test_suggestions.py | 9 +++------ 5 files changed, 9 insertions(+), 19 deletions(-) diff --git a/metricflow/engine/metricflow_engine.py b/metricflow/engine/metricflow_engine.py index ac2553b19b..f5fcc683bc 100644 --- a/metricflow/engine/metricflow_engine.py +++ b/metricflow/engine/metricflow_engine.py @@ -366,8 +366,7 @@ def __init__( self._executor = SequentialPlanExecutor() self._query_parser = MetricFlowQueryParser( - column_association_resolver=self._column_association_resolver, - model=self._semantic_manifest_lookup, + semantic_manifest_lookup=self._semantic_manifest_lookup, ) @log_call(module_name=__name__, telemetry_reporter=_telemetry_reporter) diff --git a/metricflow/query/query_parser.py b/metricflow/query/query_parser.py index 5ebb2a9365..b02d016a3d 100644 --- a/metricflow/query/query_parser.py +++ b/metricflow/query/query_parser.py @@ -47,7 +47,6 @@ ResolverInputForQuery, ResolverInputForQueryLevelWhereFilterIntersection, ) -from metricflow.specs.column_assoc import ColumnAssociationResolver from metricflow.specs.patterns.base_time_grain import BaseTimeGrainPattern from metricflow.specs.patterns.metric_time_pattern import MetricTimePattern from metricflow.specs.patterns.none_date_part import NoneDatePartPattern @@ -78,10 +77,9 @@ class MetricFlowQueryParser: def __init__( # noqa: D self, - column_association_resolver: ColumnAssociationResolver, - model: SemanticManifestLookup, + semantic_manifest_lookup: SemanticManifestLookup, ) -> None: - self._manifest_lookup = model + self._manifest_lookup = semantic_manifest_lookup self._group_by_item_naming_schemes = ( ObjectBuilderNamingScheme(), DunderNamingScheme(), diff --git a/metricflow/test/fixtures/dataflow_fixtures.py b/metricflow/test/fixtures/dataflow_fixtures.py index 5f298ddd1b..5f43620a9b 100644 --- a/metricflow/test/fixtures/dataflow_fixtures.py +++ b/metricflow/test/fixtures/dataflow_fixtures.py @@ -42,12 +42,10 @@ def dataflow_plan_builder( # noqa: D @pytest.fixture def query_parser( # noqa: D simple_semantic_manifest_lookup: SemanticManifestLookup, - column_association_resolver: ColumnAssociationResolver, consistent_id_object_repository: ConsistentIdObjectRepository, ) -> MetricFlowQueryParser: return MetricFlowQueryParser( - column_association_resolver=column_association_resolver, - model=simple_semantic_manifest_lookup, + semantic_manifest_lookup=simple_semantic_manifest_lookup, ) @@ -104,8 +102,7 @@ def scd_query_parser( # noqa: D scd_semantic_manifest_lookup: SemanticManifestLookup, ) -> MetricFlowQueryParser: return MetricFlowQueryParser( - column_association_resolver=scd_column_association_resolver, - model=scd_semantic_manifest_lookup, + semantic_manifest_lookup=scd_semantic_manifest_lookup, ) diff --git a/metricflow/test/fixtures/model_fixtures.py b/metricflow/test/fixtures/model_fixtures.py index df745baaf2..01ab676751 100644 --- a/metricflow/test/fixtures/model_fixtures.py +++ b/metricflow/test/fixtures/model_fixtures.py @@ -62,8 +62,7 @@ def query_parser_from_yaml(yaml_contents: List[YamlConfigFile]) -> MetricFlowQue ) SemanticManifestValidator[SemanticManifest]().checked_validations(semantic_manifest_lookup.semantic_manifest) return MetricFlowQueryParser( - model=semantic_manifest_lookup, - column_association_resolver=DunderColumnAssociationResolver(semantic_manifest_lookup), + semantic_manifest_lookup=semantic_manifest_lookup, ) diff --git a/metricflow/test/query/test_suggestions.py b/metricflow/test/query/test_suggestions.py index e02c940813..153eb0fe74 100644 --- a/metricflow/test/query/test_suggestions.py +++ b/metricflow/test/query/test_suggestions.py @@ -84,11 +84,9 @@ def test_suggestions_for_defined_where_filter( # noqa: D ) semantic_manifest_lookup = SemanticManifestLookup(modified_manifest) - column_association_resolver = DunderColumnAssociationResolver(modified_manifest) query_parser = MetricFlowQueryParser( - column_association_resolver=column_association_resolver, - model=semantic_manifest_lookup, + semantic_manifest_lookup=semantic_manifest_lookup, ) with pytest.raises(InvalidQueryException) as e: query_parser.parse_and_validate_query(metric_names=("listings",), group_by_names=(METRIC_TIME_ELEMENT_NAME,)) @@ -132,11 +130,10 @@ def test_suggestions_for_defined_filters_in_multi_metric_query( ) semantic_manifest_lookup = SemanticManifestLookup(modified_manifest) - column_association_resolver = DunderColumnAssociationResolver(modified_manifest) + DunderColumnAssociationResolver(modified_manifest) query_parser = MetricFlowQueryParser( - column_association_resolver=column_association_resolver, - model=semantic_manifest_lookup, + semantic_manifest_lookup=semantic_manifest_lookup, ) with pytest.raises(InvalidQueryException) as e: query_parser.parse_and_validate_query(