Skip to content

Commit

Permalink
Add marker to tests that generate SQL engine snapshosts.
Browse files Browse the repository at this point in the history
  • Loading branch information
plypaul committed Oct 30, 2023
1 parent 09f343f commit f9c195c
Show file tree
Hide file tree
Showing 13 changed files with 119 additions and 8 deletions.
3 changes: 3 additions & 0 deletions metricflow/test/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def test_list_entities(capsys: pytest.CaptureFixture, cli_runner: MetricFlowCliR
assert "host" in resp.output


@pytest.mark.sql_engine_snapshot
def test_saved_query( # noqa: D
request: FixtureRequest,
capsys: pytest.CaptureFixture,
Expand All @@ -179,6 +180,7 @@ def test_saved_query( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_saved_query_with_where( # noqa: D
request: FixtureRequest,
capsys: pytest.CaptureFixture,
Expand Down Expand Up @@ -211,6 +213,7 @@ def test_saved_query_with_where( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_saved_query_with_limit( # noqa: D
request: FixtureRequest,
capsys: pytest.CaptureFixture,
Expand Down
25 changes: 25 additions & 0 deletions metricflow/test/dataflow/builder/test_dataflow_plan_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
logger = logging.getLogger(__name__)


@pytest.mark.sql_engine_snapshot
def test_simple_plan( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down Expand Up @@ -60,6 +61,7 @@ def test_simple_plan( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_primary_entity_dimension( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down Expand Up @@ -92,6 +94,7 @@ def test_primary_entity_dimension( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_joined_plan( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down Expand Up @@ -129,6 +132,7 @@ def test_joined_plan( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_order_by_plan( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down Expand Up @@ -166,6 +170,7 @@ def test_order_by_plan( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_limit_rows_plan( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down Expand Up @@ -194,6 +199,7 @@ def test_limit_rows_plan( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_multiple_metrics_plan( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down Expand Up @@ -227,6 +233,7 @@ def test_multiple_metrics_plan( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_single_semantic_model_ratio_metrics_plan(
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down Expand Up @@ -260,6 +267,7 @@ def test_single_semantic_model_ratio_metrics_plan(
)


@pytest.mark.sql_engine_snapshot
def test_multi_semantic_model_ratio_metrics_plan(
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down Expand Up @@ -293,6 +301,7 @@ def test_multi_semantic_model_ratio_metrics_plan(
)


@pytest.mark.sql_engine_snapshot
def test_multihop_join_plan( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down Expand Up @@ -328,6 +337,7 @@ def test_multihop_join_plan( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_where_constrained_plan( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down Expand Up @@ -370,6 +380,7 @@ def test_where_constrained_plan( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_where_constrained_plan_time_dimension( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down Expand Up @@ -412,6 +423,7 @@ def test_where_constrained_plan_time_dimension( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_where_constrained_with_common_linkable_plan( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down Expand Up @@ -454,6 +466,7 @@ def test_where_constrained_with_common_linkable_plan( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_multihop_join_plan_ambiguous_dim( # noqa: D
mf_test_session_state: MetricFlowTestSessionState,
dataflow_plan_builder: DataflowPlanBuilder,
Expand All @@ -476,6 +489,7 @@ def test_multihop_join_plan_ambiguous_dim( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_cumulative_metric_with_window( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down Expand Up @@ -504,6 +518,7 @@ def test_cumulative_metric_with_window( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_cumulative_metric_no_window_or_grain_with_metric_time( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down Expand Up @@ -531,6 +546,7 @@ def test_cumulative_metric_no_window_or_grain_with_metric_time( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_cumulative_metric_no_window_or_grain_without_metric_time( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down Expand Up @@ -558,6 +574,7 @@ def test_cumulative_metric_no_window_or_grain_without_metric_time( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_distinct_values_plan( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down Expand Up @@ -605,6 +622,7 @@ def test_distinct_values_plan( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_distinct_values_plan_with_join( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down Expand Up @@ -653,6 +671,7 @@ def test_distinct_values_plan_with_join( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_measure_constraint_plan(
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down Expand Up @@ -681,6 +700,7 @@ def test_measure_constraint_plan(
)


@pytest.mark.sql_engine_snapshot
def test_measure_constraint_with_reused_measure_plan(
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down Expand Up @@ -709,6 +729,7 @@ def test_measure_constraint_with_reused_measure_plan(
)


@pytest.mark.sql_engine_snapshot
def test_common_semantic_model( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down Expand Up @@ -739,6 +760,7 @@ def test_common_semantic_model( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_derived_metric_offset_window( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down Expand Up @@ -766,6 +788,7 @@ def test_derived_metric_offset_window( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_derived_metric_offset_to_grain( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down Expand Up @@ -793,6 +816,7 @@ def test_derived_metric_offset_to_grain( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_derived_metric_offset_with_granularity( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand All @@ -819,6 +843,7 @@ def test_derived_metric_offset_with_granularity( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_derived_offset_cumulative_metric( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import pytest
from _pytest.fixtures import FixtureRequest

from metricflow.dag.id_generation import OPTIMIZED_DATAFLOW_PLAN_PREFIX, IdGeneratorRegistry
Expand Down Expand Up @@ -28,6 +29,7 @@ def make_dataflow_plan(node: BaseOutput) -> DataflowPlan: # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_read_sql_source_combination( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down Expand Up @@ -56,6 +58,7 @@ def test_read_sql_source_combination( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_filter_combination( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import logging

import pytest
from _pytest.fixtures import FixtureRequest
from dbt_semantic_interfaces.implementations.filters.where_filter import PydanticWhereFilter
from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity
Expand Down Expand Up @@ -150,6 +151,7 @@ def check_optimization( # noqa: D
assert source_counter.count_source_nodes(optimized_dataflow_plan) == expected_num_sources_in_optimized


@pytest.mark.sql_engine_snapshot
def test_2_metrics_from_1_semantic_model( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand All @@ -175,6 +177,7 @@ def test_2_metrics_from_1_semantic_model( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_2_metrics_from_2_semantic_models( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand All @@ -194,6 +197,7 @@ def test_2_metrics_from_2_semantic_models( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_3_metrics_from_2_semantic_models( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand All @@ -217,6 +221,7 @@ def test_3_metrics_from_2_semantic_models( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_constrained_metric_not_combined( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down Expand Up @@ -252,6 +257,7 @@ def test_constrained_metric_not_combined( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_derived_metric( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand All @@ -274,6 +280,7 @@ def test_derived_metric( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_nested_derived_metric( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand All @@ -297,6 +304,7 @@ def test_nested_derived_metric( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_derived_metric_with_non_derived_metric( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down Expand Up @@ -328,6 +336,7 @@ def test_derived_metric_with_non_derived_metric( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_2_ratio_metrics_from_1_semantic_model( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down
6 changes: 4 additions & 2 deletions metricflow/test/dataset/test_convert_semantic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import logging

import pytest
from _pytest.fixtures import FixtureRequest
from dbt_semantic_interfaces.references import SemanticModelReference

from metricflow.protocols.sql_client import SqlClient
from metricflow.sql.render.sql_plan_renderer import SqlQueryPlanRenderer
from metricflow.test.fixtures.model_fixtures import ConsistentIdObjectRepository
from metricflow.test.fixtures.setup_fixtures import MetricFlowTestSessionState
from metricflow.test.snapshot_utils import assert_spec_set_snapshot_equal
Expand All @@ -15,6 +15,7 @@
logger = logging.getLogger(__name__)


@pytest.mark.sql_engine_snapshot
def test_convert_table_semantic_model_without_measures( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand All @@ -40,6 +41,7 @@ def test_convert_table_semantic_model_without_measures( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_convert_table_semantic_model_with_measures( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
Expand Down Expand Up @@ -72,11 +74,11 @@ def test_convert_table_semantic_model_with_measures( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_convert_query_semantic_model( # noqa: D
request: FixtureRequest,
mf_test_session_state: MetricFlowTestSessionState,
sql_client: SqlClient,
default_sql_plan_renderer: SqlQueryPlanRenderer,
consistent_id_object_repository: ConsistentIdObjectRepository,
) -> None:
bookings_data_set = consistent_id_object_repository.simple_model_data_sets["revenue"]
Expand Down
3 changes: 3 additions & 0 deletions metricflow/test/integration/test_rendered_query.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import pytest
from _pytest.fixtures import FixtureRequest

from metricflow.dataflow.sql_table import SqlTable
Expand All @@ -12,6 +13,7 @@
_EXCLUDE_TABLE_ALIAS_REGEX = "^.*_src.*$"


@pytest.mark.sql_engine_snapshot
def test_render_query( # noqa: D
request: FixtureRequest, mf_test_session_state: MetricFlowTestSessionState, it_helpers: IntegrationTestHelpers
) -> None:
Expand All @@ -37,6 +39,7 @@ def test_render_query( # noqa: D
)


@pytest.mark.sql_engine_snapshot
def test_render_write_to_table_query( # noqa: D
request: FixtureRequest, mf_test_session_state: MetricFlowTestSessionState, it_helpers: IntegrationTestHelpers
) -> None:
Expand Down
1 change: 1 addition & 0 deletions metricflow/test/model/test_data_warehouse_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ def test_validate_measures( # noqa: D
assert len(issues.all_issues) == 2


@pytest.mark.sql_engine_snapshot
def test_build_metric_tasks( # noqa: D
request: FixtureRequest,
data_warehouse_validation_model: PydanticSemanticManifest,
Expand Down
Loading

0 comments on commit f9c195c

Please sign in to comment.