Skip to content

Commit

Permalink
Cleanup MetricFlowQueryParser initializer signature.
Browse files Browse the repository at this point in the history
  • Loading branch information
plypaul committed Jan 5, 2024
1 parent e4f7816 commit ccaf493
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 19 deletions.
3 changes: 1 addition & 2 deletions metricflow/engine/metricflow_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions metricflow/query/query_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(),
Expand Down
7 changes: 2 additions & 5 deletions metricflow/test/fixtures/dataflow_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)


Expand Down Expand Up @@ -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,
)


Expand Down
3 changes: 1 addition & 2 deletions metricflow/test/fixtures/model_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)


Expand Down
9 changes: 3 additions & 6 deletions metricflow/test/query/test_suggestions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,))
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit ccaf493

Please sign in to comment.