Skip to content

Commit

Permalink
Merge pull request #824 from dbt-labs/update-snapshots-for-saved-queries
Browse files Browse the repository at this point in the history
Add missing snapshots for saved queries
  • Loading branch information
tlento authored Oct 30, 2023
2 parents a710c27 + afbe56b commit ccd3711
Show file tree
Hide file tree
Showing 13 changed files with 108 additions and 14 deletions.
30 changes: 16 additions & 14 deletions metricflow/test/generate_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,25 +97,29 @@ def as_configurations(self) -> Sequence[MetricFlowTestConfiguration]: # noqa: D
)


SNAPSHOT_GENERATING_TEST_FILES = (
SNAPSHOT_GENERATING_TESTS = (
"metricflow/test/cli/test_cli.py::test_saved_query",
"metricflow/test/cli/test_cli.py::test_saved_query_with_where",
"metricflow/test/cli/test_cli.py::test_saved_query_with_limit",
"metricflow/test/cli/test_cli.py::test_saved_query_explain",
"metricflow/test/dataflow/builder/test_dataflow_plan_builder.py",
"metricflow/test/dataflow/optimizer/source_scan/test_cm_branch_combiner.py",
"metricflow/test/sql/optimizer/test_column_pruner.py",
"metricflow/test/dataflow/optimizer/source_scan/test_source_scan_optimizer.py",
"metricflow/test/dataset/test_convert_semantic_model.py",
"metricflow/test/integration/test_rendered_query.py",
"metricflow/test/integration/test_rendered_query.py",
"metricflow/test/model/test_data_warehouse_tasks.py",
"metricflow/test/dataflow/builder/test_dataflow_plan_builder.py",
"metricflow/test/plan_conversion/dataflow_to_sql/test_metric_time_dimension_to_sql.py",
"metricflow/test/plan_conversion/test_dataflow_to_execution.py",
"metricflow/test/plan_conversion/test_dataflow_to_sql_plan.py",
"metricflow/test/sql/test_engine_specific_rendering.py",
"metricflow/test/plan_conversion/dataflow_to_sql/test_metric_time_dimension_to_sql.py",
"metricflow/test/integration/test_rendered_query.py",
"metricflow/test/sql/optimizer/test_column_pruner.py",
"metricflow/test/sql/optimizer/test_rewriting_sub_query_reducer.py",
"metricflow/test/sql/test_sql_plan_render.py",
"metricflow/test/integration/test_rendered_query.py",
"metricflow/test/sql/optimizer/test_sub_query_reducer.py",
"metricflow/test/dataflow/optimizer/source_scan/test_source_scan_optimizer.py",
"metricflow/test/sql/test_sql_plan_render.py",
"metricflow/test/sql/optimizer/test_sub_query_reducer.py",
"metricflow/test/sql/optimizer/test_table_alias_simplifier.py",
"metricflow/test/sql/test_engine_specific_rendering.py",
"metricflow/test/sql/test_sql_plan_render.py",
"metricflow/test/sql/test_sql_plan_render.py",
)


Expand Down Expand Up @@ -178,15 +182,13 @@ def run_cli() -> None: # noqa: D

credential_sets = MetricFlowTestCredentialSetForAllEngines.parse_raw(credential_sets_json_str)

logger.info(
f"Running the following tests to generate snapshots:\n{pformat_big_objects(SNAPSHOT_GENERATING_TEST_FILES)}"
)
logger.info(f"Running the following tests to generate snapshots:\n{pformat_big_objects(SNAPSHOT_GENERATING_TESTS)}")

for test_configuration in credential_sets.as_configurations:
logger.info(
f"Running tests for {test_configuration.engine} with URL: {test_configuration.credential_set.engine_url}"
)
run_tests(test_configuration, SNAPSHOT_GENERATING_TEST_FILES)
run_tests(test_configuration, SNAPSHOT_GENERATING_TESTS)


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
| metric_time__day | listing__capacity_latest | bookings | instant_bookings |
|:--------------------|---------------------------:|-----------:|-------------------:|
| 2019-12-01 00:00:00 | 5 | 1 | 0 |
| 2020-01-01 00:00:00 | 4 | 2 | 1 |
| 2020-01-02 00:00:00 | 4 | 3 | 3 |
| 2020-01-02 00:00:00 | 5 | 1 | 0 |
| 2019-12-18 00:00:00 | 4 | 4 | 2 |
| 2020-01-03 00:00:00 | 5 | 1 | 0 |
| 2019-12-19 00:00:00 | 4 | 6 | 6 |
| 2019-12-19 00:00:00 | 5 | 2 | 0 |
| 2019-12-20 00:00:00 | 5 | 2 | 0 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
| metric_time__day | listing__capacity_latest | bookings | instant_bookings |
|:--------------------|---------------------------:|-----------:|-------------------:|
| 2019-12-01 00:00:00 | 5 | 1 | 0 |
| 2020-01-01 00:00:00 | 4 | 2 | 1 |
| 2020-01-02 00:00:00 | 4 | 3 | 3 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
| metric_time__day | listing__capacity_latest | bookings | instant_bookings |
|:--------------------|---------------------------:|-----------:|-------------------:|
| 2019-12-01 00:00:00 | 5 | 1 | 0 |
| 2020-01-02 00:00:00 | 5 | 1 | 0 |
| 2020-01-03 00:00:00 | 5 | 1 | 0 |
| 2019-12-19 00:00:00 | 5 | 2 | 0 |
| 2019-12-20 00:00:00 | 5 | 2 | 0 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
| metric_time__day | listing__capacity_latest | bookings | instant_bookings |
|:--------------------------|---------------------------:|-----------:|-------------------:|
| 2020-01-02 00:00:00+00:00 | 5 | 1 | 0 |
| 2019-12-19 00:00:00+00:00 | 4 | 6 | 6 |
| 2019-12-01 00:00:00+00:00 | 5 | 1 | 0 |
| 2019-12-20 00:00:00+00:00 | 5 | 2 | 0 |
| 2019-12-19 00:00:00+00:00 | 5 | 2 | 0 |
| 2019-12-18 00:00:00+00:00 | 4 | 4 | 2 |
| 2020-01-02 00:00:00+00:00 | 4 | 3 | 3 |
| 2020-01-03 00:00:00+00:00 | 5 | 1 | 0 |
| 2020-01-01 00:00:00+00:00 | 4 | 2 | 1 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
| metric_time__day | listing__capacity_latest | bookings | instant_bookings |
|:--------------------------|---------------------------:|-----------:|-------------------:|
| 2020-01-02 00:00:00+00:00 | 5 | 1 | 0 |
| 2019-12-19 00:00:00+00:00 | 4 | 6 | 6 |
| 2019-12-01 00:00:00+00:00 | 5 | 1 | 0 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
| metric_time__day | listing__capacity_latest | bookings | instant_bookings |
|:--------------------------|---------------------------:|-----------:|-------------------:|
| 2020-01-02 00:00:00+00:00 | 5 | 1 | 0 |
| 2019-12-01 00:00:00+00:00 | 5 | 1 | 0 |
| 2019-12-20 00:00:00+00:00 | 5 | 2 | 0 |
| 2019-12-19 00:00:00+00:00 | 5 | 2 | 0 |
| 2020-01-03 00:00:00+00:00 | 5 | 1 | 0 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
| metric_time__day | listing__capacity_latest | bookings | instant_bookings |
|:--------------------|---------------------------:|-----------:|-------------------:|
| 2019-12-19 00:00:00 | 5 | 2 | 0 |
| 2019-12-19 00:00:00 | 4 | 6 | 6 |
| 2020-01-03 00:00:00 | 5 | 1 | 0 |
| 2020-01-02 00:00:00 | 5 | 1 | 0 |
| 2019-12-20 00:00:00 | 5 | 2 | 0 |
| 2019-12-01 00:00:00 | 5 | 1 | 0 |
| 2020-01-02 00:00:00 | 4 | 3 | 3 |
| 2020-01-01 00:00:00 | 4 | 2 | 1 |
| 2019-12-18 00:00:00 | 4 | 4 | 2 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
| metric_time__day | listing__capacity_latest | bookings | instant_bookings |
|:--------------------|---------------------------:|-----------:|-------------------:|
| 2020-01-03 00:00:00 | 5 | 1 | 0 |
| 2020-01-02 00:00:00 | 5 | 1 | 0 |
| 2019-12-20 00:00:00 | 5 | 2 | 0 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
| metric_time__day | listing__capacity_latest | bookings | instant_bookings |
|:--------------------|---------------------------:|-----------:|-------------------:|
| 2019-12-19 00:00:00 | 5 | 2 | 0 |
| 2020-01-03 00:00:00 | 5 | 1 | 0 |
| 2020-01-02 00:00:00 | 5 | 1 | 0 |
| 2019-12-20 00:00:00 | 5 | 2 | 0 |
| 2019-12-01 00:00:00 | 5 | 1 | 0 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
| METRIC_TIME__DAY | LISTING__CAPACITY_LATEST | BOOKINGS | INSTANT_BOOKINGS |
|:--------------------|---------------------------:|-----------:|-------------------:|
| 2019-12-01 00:00:00 | 5 | 1 | 0 |
| 2019-12-18 00:00:00 | 4 | 4 | 2 |
| 2019-12-19 00:00:00 | 4 | 6 | 6 |
| 2019-12-19 00:00:00 | 5 | 2 | 0 |
| 2019-12-20 00:00:00 | 5 | 2 | 0 |
| 2020-01-01 00:00:00 | 4 | 2 | 1 |
| 2020-01-02 00:00:00 | 5 | 1 | 0 |
| 2020-01-02 00:00:00 | 4 | 3 | 3 |
| 2020-01-03 00:00:00 | 5 | 1 | 0 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
| METRIC_TIME__DAY | LISTING__CAPACITY_LATEST | BOOKINGS | INSTANT_BOOKINGS |
|:--------------------|---------------------------:|-----------:|-------------------:|
| 2019-12-01 00:00:00 | 5 | 1 | 0 |
| 2019-12-18 00:00:00 | 4 | 4 | 2 |
| 2019-12-19 00:00:00 | 4 | 6 | 6 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
| METRIC_TIME__DAY | LISTING__CAPACITY_LATEST | BOOKINGS | INSTANT_BOOKINGS |
|:--------------------|---------------------------:|-----------:|-------------------:|
| 2019-12-01 00:00:00 | 5 | 1 | 0 |
| 2019-12-19 00:00:00 | 5 | 2 | 0 |
| 2019-12-20 00:00:00 | 5 | 2 | 0 |
| 2020-01-02 00:00:00 | 5 | 1 | 0 |
| 2020-01-03 00:00:00 | 5 | 1 | 0 |

0 comments on commit ccd3711

Please sign in to comment.