├── metricflow ├── __init__.py ├── py.typed ├── sql │ ├── __init__.py │ ├── render │ │ ├── __init__.py │ │ └── rendering_constants.py │ └── optimizer │ │ ├── __init__.py │ │ ├── column_pruning │ │ └── __init__.py │ │ └── sql_query_plan_optimizer.py ├── data_table │ └── __init__.py ├── dataflow │ ├── __init__.py │ ├── nodes │ │ └── __init__.py │ ├── builder │ │ └── __init__.py │ └── optimizer │ │ ├── __init__.py │ │ ├── source_scan │ │ └── __init__.py │ │ └── dataflow_plan_optimizer.py ├── dataset │ └── __init__.py ├── engine │ ├── __init__.py │ └── time_source.py ├── execution │ └── __init__.py ├── protocols │ └── __init__.py ├── telemetry │ ├── __init__.py │ └── handlers │ │ └── __init__.py ├── validation │ └── __init__.py ├── plan_conversion │ ├── __init__.py │ ├── to_sql_plan │ │ └── __init__.py │ ├── instance_set_transforms │ │ └── __init__.py │ └── convert_to_sql_plan.py ├── sql_request │ ├── __init__.py │ └── sql_request_attributes.py └── __about__.py ├── scripts ├── __init__.py └── ci_tests │ └── __init__.py ├── .changes ├── unreleased │ ├── .gitkeep │ ├── Fixes-20251218-092403.yaml │ ├── Docs-20250811-160039.yaml │ ├── Under the Hood-20251002-123407.yaml │ ├── Under the Hood-20251028-110712.yaml │ ├── Under the Hood-20250924-123604.yaml │ ├── Under the Hood-20251002-123447.yaml │ ├── Fixes-20250916-121517.yaml │ ├── Under the Hood-20251002-123232.yaml │ ├── Under the Hood-20251002-131616.yaml │ ├── Under the Hood-20251008-115649.yaml │ ├── Under the Hood-20251013-140929.yaml │ ├── Under the Hood-20251030-110733.yaml │ ├── Dependencies-20251008-130706.yaml │ ├── Fixes-20251117-085411.yaml │ ├── Under the Hood-20251009-101142.yaml │ ├── Under the Hood-20251028-113955.yaml │ ├── Under the Hood-20251029-145529.yaml │ ├── Breaking Changes-20251008-115810.yaml │ ├── Fixes-20250918-070122.yaml │ ├── Fixes-20251001-153436.yaml │ ├── Under the Hood-20251002-123044.yaml │ ├── Under the Hood-20251002-131522.yaml │ ├── Under the Hood-20251117-085231.yaml │ ├── Under the Hood-20251117-085319.yaml │ ├── Fixes-20251119-233621.yaml │ ├── Fixes-20251213-093421.yaml │ ├── Under the Hood-20251002-123542.yaml │ ├── Under the Hood-20251008-120225.yaml │ ├── Under the Hood-20251009-101045.yaml │ ├── Under the Hood-20251010-132641.yaml │ ├── Under the Hood-20250924-123536.yaml │ ├── Under the Hood-20251002-122925.yaml │ ├── Under the Hood-20251009-125205.yaml │ ├── Under the Hood-20251010-132547.yaml │ ├── Under the Hood-20251010-132817.yaml │ ├── Under the Hood-20251013-140823.yaml │ ├── Under the Hood-20251013-140859.yaml │ ├── Fixes-20251015-143859.yaml │ ├── Fixes-20251023-154834.yaml │ ├── Under the Hood-20251008-120045.yaml │ ├── Under the Hood-20251008-150031.yaml │ ├── Under the Hood-20251009-101212.yaml │ ├── Under the Hood-20251008-150124.yaml │ ├── Under the Hood-20251029-140033.yaml │ ├── Dependencies-20251024-132913.yaml │ ├── Under the Hood-20251204-125847.yaml │ ├── Dependencies-20251006-144510.yaml │ ├── Breaking Changes-20251014-103322.yaml │ ├── Features-20251002-171248.yaml │ ├── Fixes-20251216-092605.yaml │ ├── Under the Hood-20251003-080025.yaml │ ├── Fixes-20251015-143827.yaml │ └── Under the Hood-20251212-122315.yaml └── v0.208.1.md ├── tests_metricflow ├── sql │ ├── __init__.py │ └── optimizer │ │ └── __init__.py ├── time │ └── __init__.py ├── dataflow │ ├── __init__.py │ ├── builder │ │ └── __init__.py │ └── optimizer │ │ ├── __init__.py │ │ └── source_scan │ │ └── __init__.py ├── dataset │ └── __init__.py ├── engine │ └── __init__.py ├── execution │ └── __init__.py ├── fixtures │ ├── __init__.py │ ├── sql_clients │ │ └── __init__.py │ ├── dbt_projects │ │ └── metricflow_testing │ │ │ ├── macros │ │ │ └── .gitkeep │ │ │ ├── seeds │ │ │ └── .gitkeep │ │ │ ├── tests │ │ │ └── .gitkeep │ │ │ ├── analyses │ │ │ └── .gitkeep │ │ │ ├── snapshots │ │ │ └── .gitkeep │ │ │ ├── .gitignore │ │ │ ├── .user.yml │ │ │ └── models │ │ │ └── example │ │ │ └── my_second_dbt_model.sql │ └── source_table_snapshots │ │ ├── data_warehouse_validation_model │ │ └── fct_animals.yaml │ │ ├── simple_multi_hop_join_manifest │ │ ├── entity_2_measure_table.yaml │ │ ├── entity_1_to_entity_0_mapping_table.yaml │ │ ├── entity_2_to_entity_0_mapping_table.yaml │ │ ├── entity_0_dimension_table.yaml │ │ ├── entity_1_dimension_table.yaml │ │ ├── entity_0_measure_table.yaml │ │ ├── entity_1_measure_table.yaml │ │ ├── entity_1_and_entity_2_measure_table.yaml │ │ └── all_entity_measure_table.yaml │ │ ├── simple_model │ │ ├── dim_companies.yaml │ │ └── dim_lux_listing_id_mapping.yaml │ │ └── multi_hop_join_model │ │ ├── third_hop_table.yaml │ │ └── bridge_table.yaml ├── prototype_utils.py ├── telemetry │ └── __init__.py ├── integration │ ├── __init__.py │ └── query_output │ │ └── __init__.py ├── mf_logging │ └── __init__.py ├── performance │ └── __init__.py ├── sql_clients │ └── __init__.py ├── table_snapshot │ ├── __init__.py │ └── example_table_snapshot.yaml ├── validation │ └── __init__.py ├── plan_conversion │ ├── __init__.py │ ├── dataflow_to_sql │ │ └── __init__.py │ └── instance_converters │ │ └── __init__.py ├── query_rendering │ └── __init__.py ├── experimental │ └── semantic_graph │ │ └── dsi │ │ └── __init__.py ├── examples │ └── __init__.py ├── __init__.py └── snapshots │ ├── test_query_output.py │ └── str │ │ └── DuckDB │ │ ├── test_scd_filter_without_metric_time__query_output.txt │ │ ├── test_scd_group_by_without_metric_time__query_output.txt │ │ └── test_semi_additive_measure_with_where_filter__query_output.txt │ ├── test_sql_plan_render.py │ └── SqlPlan │ │ ├── DuckDB │ │ ├── test_render_limit__plan0.sql │ │ ├── test_render_where__plan0.sql │ │ ├── test_render_order_by__plan0.sql │ │ ├── test_render_create_table_as__create_view_as.sql │ │ ├── test_render_create_table_as__create_table_as.sql │ │ ├── test_component_rendering__plan0.sql │ │ ├── test_component_rendering__plan1.sql │ │ └── test_component_rendering__plan2.sql │ │ ├── Trino │ │ ├── test_render_limit__plan0.sql │ │ ├── test_render_where__plan0.sql │ │ ├── test_render_order_by__plan0.sql │ │ ├── test_render_create_table_as__create_table_as.sql │ │ ├── test_render_create_table_as__create_view_as.sql │ │ ├── test_component_rendering__plan0.sql │ │ ├── test_component_rendering__plan1.sql │ │ └── test_component_rendering__plan2.sql │ │ ├── BigQuery │ │ ├── test_render_limit__plan0.sql │ │ ├── test_render_where__plan0.sql │ │ ├── test_render_order_by__plan0.sql │ │ ├── test_render_create_table_as__create_table_as.sql │ │ ├── test_render_create_table_as__create_view_as.sql │ │ ├── test_component_rendering__plan0.sql │ │ ├── test_component_rendering__plan1.sql │ │ └── test_component_rendering__plan2.sql │ │ ├── Postgres │ │ ├── test_render_limit__plan0.sql │ │ ├── test_render_where__plan0.sql │ │ ├── test_render_order_by__plan0.sql │ │ ├── test_render_create_table_as__create_table_as.sql │ │ ├── test_render_create_table_as__create_view_as.sql │ │ ├── test_component_rendering__plan0.sql │ │ ├── test_component_rendering__plan1.sql │ │ └── test_component_rendering__plan2.sql │ │ ├── Redshift │ │ ├── test_render_limit__plan0.sql │ │ ├── test_render_where__plan0.sql │ │ ├── test_render_order_by__plan0.sql │ │ ├── test_render_create_table_as__create_table_as.sql │ │ ├── test_render_create_table_as__create_view_as.sql │ │ ├── test_component_rendering__plan0.sql │ │ ├── test_component_rendering__plan1.sql │ │ └── test_component_rendering__plan2.sql │ │ ├── Databricks │ │ ├── test_render_limit__plan0.sql │ │ ├── test_render_where__plan0.sql │ │ ├── test_render_order_by__plan0.sql │ │ ├── test_render_create_table_as__create_table_as.sql │ │ ├── test_render_create_table_as__create_view_as.sql │ │ ├── test_component_rendering__plan0.sql │ │ ├── test_component_rendering__plan1.sql │ │ └── test_component_rendering__plan2.sql │ │ └── Snowflake │ │ ├── test_render_limit__plan0.sql │ │ ├── test_render_where__plan0.sql │ │ ├── test_render_order_by__plan0.sql │ │ ├── test_render_create_table_as__create_view_as.sql │ │ ├── test_render_create_table_as__create_table_as.sql │ │ ├── test_component_rendering__plan0.sql │ │ ├── test_component_rendering__plan1.sql │ │ └── test_component_rendering__plan2.sql │ ├── test_engine_specific_rendering.py │ └── SqlPlan │ │ ├── Trino │ │ ├── test_generate_uuid__plan0.sql │ │ ├── test_add_time_expr__plan0.sql │ │ ├── test_cast_to_timestamp__plan0.sql │ │ └── test_approximate_continuous_percentile_expr__plan0.sql │ │ ├── Databricks │ │ ├── test_generate_uuid__plan0.sql │ │ ├── test_add_time_expr__plan0.sql │ │ ├── test_cast_to_timestamp__plan0.sql │ │ ├── test_continuous_percentile_expr__plan0.sql │ │ └── test_approximate_discrete_percentile_expr__plan0.sql │ │ ├── BigQuery │ │ ├── test_generate_uuid__plan0.sql │ │ ├── test_cast_to_timestamp__plan0.sql │ │ ├── test_add_time_expr__plan0.sql │ │ └── test_approximate_continuous_percentile_expr__plan0.sql │ │ ├── DuckDB │ │ ├── test_generate_uuid__plan0.sql │ │ ├── test_add_time_expr__plan0.sql │ │ ├── test_cast_to_timestamp__plan0.sql │ │ ├── test_discrete_percentile_expr__plan0.sql │ │ ├── test_continuous_percentile_expr__plan0.sql │ │ └── test_approximate_continuous_percentile_expr__plan0.sql │ │ ├── Postgres │ │ ├── test_generate_uuid__plan0.sql │ │ ├── test_cast_to_timestamp__plan0.sql │ │ ├── test_add_time_expr__plan0.sql │ │ ├── test_discrete_percentile_expr__plan0.sql │ │ └── test_continuous_percentile_expr__plan0.sql │ │ ├── Snowflake │ │ ├── test_generate_uuid__plan0.sql │ │ ├── test_add_time_expr__plan0.sql │ │ ├── test_cast_to_timestamp__plan0.sql │ │ ├── test_discrete_percentile_expr__plan0.sql │ │ ├── test_continuous_percentile_expr__plan0.sql │ │ └── test_approximate_continuous_percentile_expr__plan0.sql │ │ └── Redshift │ │ ├── test_add_time_expr__plan0.sql │ │ ├── test_cast_to_timestamp__plan0.sql │ │ ├── test_generate_uuid__plan0.sql │ │ ├── test_continuous_percentile_expr__plan0.sql │ │ └── test_approximate_discrete_percentile_expr__plan0.sql │ ├── test_mf_engine.py │ └── list │ │ ├── test_list_saved_queries__result0.txt │ │ ├── test_entities_for_metrics__result0.txt │ │ └── test_list_dimensions_for_metrics_for_multiple_metrics__result0.txt │ ├── test_conversion_metrics.py │ └── str │ │ ├── DuckDB │ │ ├── test_conversion_metric_with_filter_not_in_group_by__query_output.txt │ │ ├── test_conversion_metric_with_time_constraint__query_output.txt │ │ └── test_conversion_metric_with_different_time_dimension_grains__query_output.txt │ │ ├── Trino │ │ ├── test_conversion_metric_with_filter_not_in_group_by__query_output.txt │ │ ├── test_conversion_metric_with_time_constraint__query_output.txt │ │ └── test_conversion_metric_with_different_time_dimension_grains__query_output.txt │ │ ├── BigQuery │ │ ├── test_conversion_metric_with_filter_not_in_group_by__query_output.txt │ │ ├── test_conversion_metric_with_time_constraint__query_output.txt │ │ └── test_conversion_metric_with_different_time_dimension_grains__query_output.txt │ │ ├── Databricks │ │ ├── test_conversion_metric_with_filter_not_in_group_by__query_output.txt │ │ ├── test_conversion_metric_with_time_constraint__query_output.txt │ │ └── test_conversion_metric_with_different_time_dimension_grains__query_output.txt │ │ ├── Postgres │ │ ├── test_conversion_metric_with_filter_not_in_group_by__query_output.txt │ │ ├── test_conversion_metric_with_time_constraint__query_output.txt │ │ └── test_conversion_metric_with_different_time_dimension_grains__query_output.txt │ │ ├── Redshift │ │ ├── test_conversion_metric_with_filter_not_in_group_by__query_output.txt │ │ ├── test_conversion_metric_with_time_constraint__query_output.txt │ │ └── test_conversion_metric_with_different_time_dimension_grains__query_output.txt │ │ └── Snowflake │ │ ├── test_conversion_metric_with_filter_not_in_group_by__query_output.txt │ │ ├── test_conversion_metric_with_time_constraint__query_output.txt │ │ └── test_conversion_metric_with_different_time_dimension_grains__query_output.txt │ ├── test_fill_nulls_with_0.py │ └── str │ │ ├── DuckDB │ │ ├── test_join_to_time_spine_with_filter_smaller_than_group_by__query_output.txt │ │ ├── test_join_to_timespine_metric_with_custom_granularity_filter__query_output.txt │ │ ├── test_join_to_time_spine_with_filter_not_in_group_by__query_output.txt │ │ ├── test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__query_output.txt │ │ ├── test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__query_output.txt │ │ └── test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt │ │ ├── BigQuery │ │ ├── test_join_to_time_spine_with_filter_smaller_than_group_by__query_output.txt │ │ ├── test_join_to_timespine_metric_with_custom_granularity_filter__query_output.txt │ │ ├── test_join_to_time_spine_with_filter_not_in_group_by__query_output.txt │ │ ├── test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__query_output.txt │ │ ├── test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__query_output.txt │ │ └── test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt │ │ ├── Databricks │ │ ├── test_join_to_time_spine_with_filter_smaller_than_group_by__query_output.txt │ │ ├── test_join_to_timespine_metric_with_custom_granularity_filter__query_output.txt │ │ ├── test_join_to_time_spine_with_filter_not_in_group_by__query_output.txt │ │ ├── test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__query_output.txt │ │ ├── test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__query_output.txt │ │ └── test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt │ │ ├── Postgres │ │ ├── test_join_to_time_spine_with_filter_smaller_than_group_by__query_output.txt │ │ ├── test_join_to_timespine_metric_with_custom_granularity_filter__query_output.txt │ │ ├── test_join_to_time_spine_with_filter_not_in_group_by__query_output.txt │ │ ├── test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__query_output.txt │ │ ├── test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__query_output.txt │ │ └── test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt │ │ ├── Redshift │ │ ├── test_join_to_time_spine_with_filter_smaller_than_group_by__query_output.txt │ │ ├── test_join_to_timespine_metric_with_custom_granularity_filter__query_output.txt │ │ ├── test_join_to_time_spine_with_filter_not_in_group_by__query_output.txt │ │ ├── test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__query_output.txt │ │ ├── test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__query_output.txt │ │ └── test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt │ │ ├── Snowflake │ │ ├── test_join_to_time_spine_with_filter_smaller_than_group_by__query_output.txt │ │ ├── test_join_to_timespine_metric_with_custom_granularity_filter__query_output.txt │ │ ├── test_join_to_time_spine_with_filter_not_in_group_by__query_output.txt │ │ ├── test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__query_output.txt │ │ ├── test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__query_output.txt │ │ └── test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt │ │ └── Trino │ │ └── test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt │ ├── test_column_pruner.py │ └── SqlPlan │ │ ├── test_prune_distinct_select__after_pruning.sql │ │ └── test_prune_distinct_select__before_pruning.sql │ ├── test_data_warehouse_tasks.py │ └── str │ │ ├── Trino │ │ └── test_build_metric_tasks__query0.sql │ │ ├── DuckDB │ │ └── test_build_metric_tasks__query0.sql │ │ ├── BigQuery │ │ └── test_build_metric_tasks__query0.sql │ │ ├── Databricks │ │ └── test_build_metric_tasks__query0.sql │ │ ├── Postgres │ │ └── test_build_metric_tasks__query0.sql │ │ ├── Redshift │ │ └── test_build_metric_tasks__query0.sql │ │ └── Snowflake │ │ └── test_build_metric_tasks__query0.sql │ ├── test_rewriting_sub_query_reducer.py │ └── SqlPlan │ │ ├── test_rewriting_distinct_select_node_is_not_reduced__after_reducing.sql │ │ └── test_rewriting_distinct_select_node_is_not_reduced__before_reducing.sql │ └── test_dataflow_to_sql_plan.py │ └── SqlPlan │ └── DuckDB │ └── test_filter_node__plan0_optimized.sql ├── dbt-metricflow ├── dbt_metricflow │ ├── py.typed │ ├── __init__.py │ ├── cli │ │ ├── dbt_connectors │ │ │ └── __init__.py │ │ ├── sample_dbt_models │ │ │ ├── seeds │ │ │ │ ├── .gitkeep │ │ │ │ ├── countries_seed.csv │ │ │ │ └── customers_seed.csv │ │ │ ├── sample_models │ │ │ │ ├── countries.sql │ │ │ │ ├── customers.sql │ │ │ │ ├── transactions.sql │ │ │ │ └── countries.yml │ │ │ └── sources.yml │ │ ├── __init__.py │ │ ├── mf_tutorial_project │ │ │ ├── profiles.yml │ │ │ ├── dbt_project.yml │ │ │ └── models │ │ │ │ └── _models.yml │ │ ├── sample_models │ │ │ └── project_configuration.yaml │ │ ├── constants.py │ │ ├── cli_string.py │ │ └── cli_errors.py │ └── __about__.py ├── tests_dbt_metricflow │ ├── cli │ │ ├── __init__.py │ │ └── demo_data_types_project_add_on │ │ │ ├── models │ │ │ ├── demo_data_types.sql │ │ │ └── metrics.yml │ │ │ ├── seeds │ │ │ └── properties.yml │ │ │ └── __init__.py │ ├── fixtures │ │ └── __init__.py │ ├── conftest.py │ ├── snapshots │ │ ├── test_cli.py │ │ │ └── str │ │ │ │ ├── test_health_checks__result.txt │ │ │ │ ├── test_get_dimension_values__result.txt │ │ │ │ ├── test_list_entities__result.txt │ │ │ │ ├── test_csv__result.txt │ │ │ │ ├── test_list_dimensions__result.txt │ │ │ │ └── test_list_saved_queries__result.txt │ │ ├── test_isolated_command_runner.py │ │ │ └── str │ │ │ │ ├── test_isolated_query__result.txt │ │ │ │ └── test_environment_variables__result.txt │ │ └── test_output_format.py │ │ │ └── str │ │ │ ├── test_decimals_option_negative__result.txt │ │ │ └── test_decimals_option_invalid__result.txt │ └── __init__.py └── requirements-files │ ├── requirements-dbt-duckdb.txt │ ├── requirements-dbt-trino.txt │ ├── requirements-dbt-bigquery.txt │ ├── requirements-dbt-postgres.txt │ ├── requirements-dbt-redshift.txt │ ├── requirements-dbt-snowflake.txt │ ├── requirements-dbt-databricks.txt │ ├── requirements-metricflow.txt │ ├── requirements-cli.txt │ └── dev-env-requirements.txt ├── metricflow-semantic-interfaces ├── tests │ ├── __init__.py │ ├── fixtures │ │ ├── __init__.py │ │ └── semantic_manifest_yamls │ │ │ └── simple_semantic_manifest │ │ │ └── semantic_models │ │ │ └── lux_listing_mapping.yaml │ ├── parsing │ │ └── __init__.py │ ├── serialization │ │ └── __init__.py │ ├── validations │ │ └── __init__.py │ ├── implementations │ │ ├── __init__.py │ │ └── where_filter │ │ │ └── __init__.py │ ├── transformations │ │ └── __init__.py │ └── conftest.py └── metricflow_semantic_interfaces │ ├── __init__.py │ ├── py.typed │ ├── naming │ ├── __init__.py │ └── keywords.py │ ├── parsing │ ├── __init__.py │ └── text_input │ │ └── __init__.py │ ├── test_helpers │ └── __init__.py │ ├── validations │ └── __init__.py │ ├── implementations │ ├── __init__.py │ ├── elements │ │ └── __init__.py │ ├── filters │ │ └── __init__.py │ └── metadata.py │ ├── transformations │ ├── __init__.py │ └── boolean_measure.py │ ├── type_enums │ ├── export_destination_type.py │ ├── period_agg.py │ ├── conversion_calculation_type.py │ ├── metric_type.py │ ├── semantic_manifest_node_type.py │ ├── entity_type.py │ ├── dimension_type.py │ └── aggregation_type.py │ └── protocols │ └── meta.py ├── .github ├── CODEOWNERS └── atlas.yaml ├── metricflow-semantics ├── metricflow_semantics │ ├── __init__.py │ ├── py.typed │ ├── api │ │ ├── __init__.py │ │ └── v0_1 │ │ │ └── __init__.py │ ├── dag │ │ └── __init__.py │ ├── sql │ │ ├── __init__.py │ │ └── sql_column_type.py │ ├── time │ │ ├── __init__.py │ │ ├── time_constants.py │ │ └── time_source.py │ ├── errors │ │ └── __init__.py │ ├── filters │ │ └── __init__.py │ ├── model │ │ ├── __init__.py │ │ └── semantics │ │ │ └── __init__.py │ ├── naming │ │ └── __init__.py │ ├── protocols │ │ └── __init__.py │ ├── query │ │ ├── __init__.py │ │ ├── issues │ │ │ ├── __init__.py │ │ │ ├── parsing │ │ │ │ └── __init__.py │ │ │ ├── filter_spec_resolver │ │ │ │ └── __init__.py │ │ │ └── group_by_item_resolver │ │ │ │ └── __init__.py │ │ ├── group_by_item │ │ │ ├── __init__.py │ │ │ ├── resolution_dag │ │ │ │ ├── __init__.py │ │ │ │ └── resolution_nodes │ │ │ │ │ └── __init__.py │ │ │ ├── candidate_push_down │ │ │ │ └── __init__.py │ │ │ └── filter_spec_resolution │ │ │ │ └── __init__.py │ │ ├── resolver_inputs │ │ │ └── __init__.py │ │ └── validation_rules │ │ │ └── __init__.py │ ├── specs │ │ ├── __init__.py │ │ ├── patterns │ │ │ └── __init__.py │ │ └── where_filter │ │ │ └── __init__.py │ ├── experimental │ │ └── __init__.py │ ├── semantic_graph │ │ ├── __init__.py │ │ ├── builder │ │ │ └── __init__.py │ │ ├── edges │ │ │ └── __init__.py │ │ ├── lookups │ │ │ └── __init__.py │ │ ├── nodes │ │ │ └── __init__.py │ │ ├── trie_resolver │ │ │ └── __init__.py │ │ ├── attribute_resolution │ │ │ └── __init__.py │ │ └── sg_exceptions.py │ ├── test_helpers │ │ ├── __init__.py │ │ ├── performance │ │ │ └── __init__.py │ │ ├── synthetic_manifest │ │ │ └── __init__.py │ │ └── semantic_manifest_yamls │ │ │ ├── non_sm_manifest │ │ │ ├── project_configuration.yaml │ │ │ └── __init__.py │ │ │ ├── scd_manifest │ │ │ ├── project_configuration.yaml │ │ │ ├── __init__.py │ │ │ └── scd_users.yaml │ │ │ ├── simple_manifest │ │ │ ├── project_configuration.yaml │ │ │ ├── __init__.py │ │ │ └── semantic_models │ │ │ │ └── lux_listing_mapping.yaml │ │ │ ├── cyclic_join_manifest │ │ │ ├── project_configuration.yaml │ │ │ └── __init__.py │ │ │ ├── join_types_manifest │ │ │ ├── project_configuration.yaml │ │ │ ├── __init__.py │ │ │ └── listings_source.yaml │ │ │ ├── config_linter_manifest │ │ │ ├── project_configuration.yaml │ │ │ └── __init__.py │ │ │ ├── extended_date_manifest │ │ │ ├── project_configuration.yaml │ │ │ ├── __init__.py │ │ │ └── metrics │ │ │ │ ├── bookings_cumulative.yaml │ │ │ │ ├── bookings_monthly_cumulative.yaml │ │ │ │ ├── bookings_last_month.yaml │ │ │ │ └── monthly_bookings_to_daily_bookings_ratio.yaml │ │ │ ├── multi_hop_join_manifest │ │ │ ├── project_configuration.yaml │ │ │ ├── __init__.py │ │ │ ├── metrics.yaml │ │ │ ├── third_hop_table.yaml │ │ │ ├── bridge_table.yaml │ │ │ └── customer_table.yaml │ │ │ ├── name_edge_case_manifest │ │ │ ├── project_configuration.yaml │ │ │ └── __init__.py │ │ │ ├── ambiguous_resolution_manifest │ │ │ ├── project_configuration.yaml │ │ │ └── __init__.py │ │ │ ├── simple_multi_hop_join_manifest │ │ │ ├── project_configuration.yaml │ │ │ ├── __init__.py │ │ │ ├── entity_1_to_entity_0_mapping_source.yaml │ │ │ ├── entity_2_to_entity_0_mapping_source.yaml │ │ │ ├── entity_0_dimension_source.yaml │ │ │ └── entity_1_dimension_source.yaml │ │ │ ├── data_warehouse_validation_manifest │ │ │ ├── project_configuration.yaml │ │ │ └── __init__.py │ │ │ ├── partitioned_multi_hop_join_manifest │ │ │ ├── project_configuration.yaml │ │ │ ├── __init__.py │ │ │ └── metrics.yaml │ │ │ ├── __init__.py │ │ │ ├── sg_02_single_join │ │ │ └── __init__.py │ │ │ ├── sg_00_minimal_manifest │ │ │ └── __init__.py │ │ │ └── sg_05_derived_metric │ │ │ └── __init__.py │ ├── toolkit │ │ ├── cache │ │ │ └── __init__.py │ │ ├── collections │ │ │ └── __init__.py │ │ ├── mf_graph │ │ │ ├── __init__.py │ │ │ ├── formatting │ │ │ │ └── __init__.py │ │ │ └── path_finding │ │ │ │ └── __init__.py │ │ ├── mf_logging │ │ │ └── __init__.py │ │ └── __init__.py │ └── __about__.py ├── tests_metricflow_semantics │ ├── api │ │ ├── __init__.py │ │ └── v0_1 │ │ │ └── __init__.py │ ├── dag │ │ └── __init__.py │ ├── sql │ │ └── __init__.py │ ├── fixtures │ │ └── __init__.py │ ├── helpers │ │ ├── __init__.py │ │ └── performance │ │ │ └── __init__.py │ ├── model │ │ ├── __init__.py │ │ ├── modify │ │ │ └── __init__.py │ │ └── semantics │ │ │ └── __init__.py │ ├── naming │ │ └── __init__.py │ ├── query │ │ ├── __init__.py │ │ ├── errors │ │ │ └── __init__.py │ │ └── group_by_item │ │ │ ├── __init__.py │ │ │ ├── resolution_dag │ │ │ └── __init__.py │ │ │ └── filter_spec_resolution │ │ │ └── __init__.py │ ├── specs │ │ ├── __init__.py │ │ ├── patterns │ │ │ └── __init__.py │ │ └── conftest.py │ ├── time │ │ └── __init__.py │ ├── toolkit │ │ ├── __init__.py │ │ ├── cache │ │ │ └── __init__.py │ │ ├── mf_graph │ │ │ ├── __init__.py │ │ │ ├── formatting │ │ │ │ └── __init__.py │ │ │ └── path_finding │ │ │ │ └── __init__.py │ │ ├── collections │ │ │ └── __init__.py │ │ └── test_ordered_enum.py │ ├── experimental │ │ └── __init__.py │ ├── mf_logging │ │ └── __init__.py │ ├── semantic_graph │ │ ├── __init__.py │ │ ├── builder │ │ │ └── __init__.py │ │ ├── lookups │ │ │ └── __init__.py │ │ ├── resolver │ │ │ └── __init__.py │ │ ├── trie_resolver │ │ │ └── __init__.py │ │ └── attribute_resolution │ │ │ └── __init__.py │ ├── __init__.py │ ├── snapshots │ │ ├── test_spec_lookup.py │ │ │ └── str │ │ │ │ └── test_filter_spec_resolution__no_metrics__result.txt │ │ ├── test_snapshot.py │ │ │ └── str │ │ │ │ └── test_expectation_description__result.txt │ │ ├── test_available_group_by_items.py │ │ │ └── LinkableSpecSet │ │ │ │ ├── test_available_group_by_items__metrics_with_different_time_grains__set0.txt │ │ │ │ └── test_available_group_by_items__derived_metric_with_different_parent_time_grains__set0.txt │ │ ├── test_messages.py │ │ │ └── str │ │ │ │ ├── test_empty_query__result.txt │ │ │ │ └── test_long_invalid_metric__result.txt │ │ ├── test_dot.py │ │ │ └── str │ │ │ │ └── test_dot_text__result.txt │ │ ├── test_path_finder.py │ │ │ ├── FindAncestorsResult │ │ │ │ └── test_find_ancestors__result.txt │ │ │ └── FindDescendantsResult │ │ │ │ └── test_find_descendants__result.txt │ │ └── test_suggestions.py │ │ │ └── str │ │ │ └── test_suggestions_for_metric__result_0.txt │ └── conftest.py └── requirements-files │ ├── requirements.txt │ └── dev-env-requirements.txt ├── .gitattributes ├── assets └── MetricFlow_logo.png ├── local-data-warehouses ├── trino │ └── docker-compose.yaml ├── Makefile └── postgresql │ └── docker-compose.yaml ├── requirements-files ├── requirements.txt └── dev-env-requirements.txt └── pytest.ini /metricflow/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /scripts/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.changes/unreleased/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow/sql/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /scripts/ci_tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow/data_table/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow/dataflow/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow/dataset/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow/engine/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow/execution/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow/protocols/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow/sql/render/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow/telemetry/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow/validation/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/sql/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/time/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /dbt-metricflow/dbt_metricflow/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow/dataflow/nodes/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow/plan_conversion/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow/sql/optimizer/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow/sql_request/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/dataflow/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/dataset/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/engine/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/execution/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/fixtures/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/prototype_utils.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/telemetry/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /dbt-metricflow/dbt_metricflow/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow/dataflow/builder/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow/dataflow/optimizer/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow/telemetry/handlers/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/integration/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/mf_logging/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/performance/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/sql/optimizer/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/sql_clients/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/table_snapshot/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/validation/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/dataflow/builder/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/dataflow/optimizer/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/plan_conversion/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/query_rendering/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @dbt-labs/semantic-layer 2 | -------------------------------------------------------------------------------- /dbt-metricflow/tests_dbt_metricflow/cli/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow/dataflow/optimizer/source_scan/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow/plan_conversion/to_sql_plan/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow/sql/optimizer/column_pruning/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/fixtures/sql_clients/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/integration/query_output/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /dbt-metricflow/tests_dbt_metricflow/fixtures/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/tests/fixtures/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/tests/parsing/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/api/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/dag/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/sql/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/time/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | tests/snapshots/* linguist-generated=true 2 | -------------------------------------------------------------------------------- /dbt-metricflow/dbt_metricflow/cli/dbt_connectors/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/tests/serialization/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/tests/validations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/api/v0_1/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/errors/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/filters/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/model/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/naming/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/protocols/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/query/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/specs/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/api/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/dag/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/sql/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow/plan_conversion/instance_set_transforms/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/dataflow/optimizer/source_scan/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/experimental/semantic_graph/dsi/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/plan_conversion/dataflow_to_sql/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /dbt-metricflow/dbt_metricflow/cli/sample_dbt_models/seeds/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/tests/implementations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/tests/transformations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/experimental/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/query/issues/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/semantic_graph/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/specs/patterns/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/toolkit/cache/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/api/v0_1/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/fixtures/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/helpers/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/model/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/naming/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/query/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/specs/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/time/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/toolkit/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/plan_conversion/instance_converters/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/metricflow_semantic_interfaces/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/metricflow_semantic_interfaces/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/model/semantics/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/query/group_by_item/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/specs/where_filter/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/toolkit/collections/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/toolkit/mf_graph/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/toolkit/mf_logging/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/experimental/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/mf_logging/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/model/modify/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/query/errors/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/toolkit/cache/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/fixtures/dbt_projects/metricflow_testing/macros/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/fixtures/dbt_projects/metricflow_testing/seeds/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/fixtures/dbt_projects/metricflow_testing/tests/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /dbt-metricflow/requirements-files/requirements-dbt-duckdb.txt: -------------------------------------------------------------------------------- 1 | dbt-duckdb 2 | -------------------------------------------------------------------------------- /dbt-metricflow/requirements-files/requirements-dbt-trino.txt: -------------------------------------------------------------------------------- 1 | dbt-trino 2 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/tests/implementations/where_filter/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/query/issues/parsing/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/query/resolver_inputs/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/query/validation_rules/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/semantic_graph/builder/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/semantic_graph/edges/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/semantic_graph/lookups/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/semantic_graph/nodes/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/performance/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/model/semantics/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/semantic_graph/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/specs/patterns/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/toolkit/mf_graph/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/fixtures/dbt_projects/metricflow_testing/analyses/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/fixtures/dbt_projects/metricflow_testing/snapshots/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /dbt-metricflow/requirements-files/requirements-dbt-bigquery.txt: -------------------------------------------------------------------------------- 1 | dbt-bigquery 2 | -------------------------------------------------------------------------------- /dbt-metricflow/requirements-files/requirements-dbt-postgres.txt: -------------------------------------------------------------------------------- 1 | dbt-postgres 2 | -------------------------------------------------------------------------------- /dbt-metricflow/requirements-files/requirements-dbt-redshift.txt: -------------------------------------------------------------------------------- 1 | dbt-redshift 2 | -------------------------------------------------------------------------------- /dbt-metricflow/requirements-files/requirements-dbt-snowflake.txt: -------------------------------------------------------------------------------- 1 | dbt-snowflake 2 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/metricflow_semantic_interfaces/naming/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/metricflow_semantic_interfaces/parsing/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/semantic_graph/trie_resolver/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/toolkit/mf_graph/formatting/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/toolkit/mf_graph/path_finding/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/helpers/performance/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/query/group_by_item/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/semantic_graph/builder/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/semantic_graph/lookups/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/semantic_graph/resolver/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/toolkit/collections/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /dbt-metricflow/requirements-files/requirements-dbt-databricks.txt: -------------------------------------------------------------------------------- 1 | dbt-databricks 2 | -------------------------------------------------------------------------------- /dbt-metricflow/requirements-files/requirements-metricflow.txt: -------------------------------------------------------------------------------- 1 | metricflow==0.209.0 2 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/metricflow_semantic_interfaces/test_helpers/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/metricflow_semantic_interfaces/validations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/query/group_by_item/resolution_dag/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/query/issues/filter_spec_resolver/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/synthetic_manifest/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/semantic_graph/trie_resolver/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/toolkit/mf_graph/formatting/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/metricflow_semantic_interfaces/implementations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/metricflow_semantic_interfaces/parsing/text_input/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/metricflow_semantic_interfaces/transformations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/query/group_by_item/candidate_push_down/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/query/issues/group_by_item_resolver/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/semantic_graph/attribute_resolution/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/toolkit/mf_graph/path_finding/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/metricflow_semantic_interfaces/implementations/elements/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/metricflow_semantic_interfaces/implementations/filters/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/query/group_by_item/filter_spec_resolution/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/query/group_by_item/resolution_dag/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/semantic_graph/attribute_resolution/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /metricflow/__about__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | __version__ = "0.209.0" 4 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/query/group_by_item/filter_spec_resolution/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/MetricFlow_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dbt-labs/metricflow/HEAD/assets/MetricFlow_logo.png -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/query/group_by_item/resolution_dag/resolution_nodes/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests_metricflow/examples/__init__.py: -------------------------------------------------------------------------------- 1 | """Example test cases that may be helpful to new developers.""" 2 | -------------------------------------------------------------------------------- /dbt-metricflow/dbt_metricflow/__about__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | __version__ = "0.11.0" 4 | -------------------------------------------------------------------------------- /tests_metricflow/fixtures/dbt_projects/metricflow_testing/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | target/ 3 | dbt_packages/ 4 | logs/ 5 | -------------------------------------------------------------------------------- /tests_metricflow/fixtures/dbt_projects/metricflow_testing/.user.yml: -------------------------------------------------------------------------------- 1 | id: 76fe6b46-c8bf-4a1c-941b-b3f76dbbe58e 2 | -------------------------------------------------------------------------------- /dbt-metricflow/dbt_metricflow/cli/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | PACKAGE_NAME = "dbt-metricflow" 4 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/__about__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | __version__ = "0.3.0.dev0" 4 | -------------------------------------------------------------------------------- /.github/atlas.yaml: -------------------------------------------------------------------------------- 1 | github_team: semantic-layer 2 | issue_project: SL 3 | issue_system: linear 4 | slack_channel: semantic-layer-alerts 5 | -------------------------------------------------------------------------------- /dbt-metricflow/dbt_metricflow/cli/sample_dbt_models/sample_models/countries.sql: -------------------------------------------------------------------------------- 1 | select 2 | * 3 | from {{ref('countries_seed')}} 4 | -------------------------------------------------------------------------------- /dbt-metricflow/dbt_metricflow/cli/sample_dbt_models/sample_models/customers.sql: -------------------------------------------------------------------------------- 1 | select 2 | * 3 | from {{ref('customers_seed')}} 4 | -------------------------------------------------------------------------------- /dbt-metricflow/dbt_metricflow/cli/sample_dbt_models/sample_models/transactions.sql: -------------------------------------------------------------------------------- 1 | select 2 | * 3 | from {{ref('transactions_seed')}} 4 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/toolkit/__init__.py: -------------------------------------------------------------------------------- 1 | """Utility classes and methods that are sufficiently general to use across projects.""" 2 | -------------------------------------------------------------------------------- /dbt-metricflow/dbt_metricflow/cli/sample_dbt_models/seeds/countries_seed.csv: -------------------------------------------------------------------------------- 1 | country,region 2 | US,NA 3 | MX,NA 4 | CA,NA 5 | BR,SA 6 | GR,EU 7 | FR,EU 8 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/non_sm_manifest/project_configuration.yaml: -------------------------------------------------------------------------------- 1 | ../shared/project_configuration.yaml -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/scd_manifest/project_configuration.yaml: -------------------------------------------------------------------------------- 1 | ../shared/project_configuration.yaml -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/simple_manifest/project_configuration.yaml: -------------------------------------------------------------------------------- 1 | ../shared/project_configuration.yaml -------------------------------------------------------------------------------- /dbt-metricflow/tests_dbt_metricflow/cli/demo_data_types_project_add_on/models/demo_data_types.sql: -------------------------------------------------------------------------------- 1 | select 2 | * 3 | from {{ref('demo_data_types_seed')}} 4 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/cyclic_join_manifest/project_configuration.yaml: -------------------------------------------------------------------------------- 1 | ../shared/project_configuration.yaml -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/join_types_manifest/project_configuration.yaml: -------------------------------------------------------------------------------- 1 | ../shared/project_configuration.yaml -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/config_linter_manifest/project_configuration.yaml: -------------------------------------------------------------------------------- 1 | ../shared/project_configuration.yaml -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/extended_date_manifest/project_configuration.yaml: -------------------------------------------------------------------------------- 1 | ../shared/project_configuration.yaml -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/multi_hop_join_manifest/project_configuration.yaml: -------------------------------------------------------------------------------- 1 | ../shared/project_configuration.yaml -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/name_edge_case_manifest/project_configuration.yaml: -------------------------------------------------------------------------------- 1 | ../shared/project_configuration.yaml -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/ambiguous_resolution_manifest/project_configuration.yaml: -------------------------------------------------------------------------------- 1 | ../shared/project_configuration.yaml -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/simple_multi_hop_join_manifest/project_configuration.yaml: -------------------------------------------------------------------------------- 1 | ../shared/project_configuration.yaml -------------------------------------------------------------------------------- /dbt-metricflow/tests_dbt_metricflow/conftest.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from tests_dbt_metricflow.fixtures.setup_fixtures import * # noqa: F401, F403 4 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/data_warehouse_validation_manifest/project_configuration.yaml: -------------------------------------------------------------------------------- 1 | ../shared/project_configuration.yaml -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/partitioned_multi_hop_join_manifest/project_configuration.yaml: -------------------------------------------------------------------------------- 1 | ../shared/project_configuration.yaml -------------------------------------------------------------------------------- /dbt-metricflow/dbt_metricflow/cli/mf_tutorial_project/profiles.yml: -------------------------------------------------------------------------------- 1 | mf_tutorial: 2 | target: dev 3 | outputs: 4 | dev: 5 | type: duckdb 6 | path: $db_file_path 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Fixes-20251218-092403.yaml: -------------------------------------------------------------------------------- 1 | kind: Fixes 2 | body: Fix logging setup in the CLI 3 | time: 2025-12-18T09:24:03.655615-08:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1932" 7 | -------------------------------------------------------------------------------- /dbt-metricflow/dbt_metricflow/cli/sample_dbt_models/seeds/customers_seed.csv: -------------------------------------------------------------------------------- 1 | id_customer,country,ds 2 | c500001,FR,2022-03-07 3 | c500003,MX,2022-03-08 4 | c500000,US,2022-03-10 5 | c500002,CA,2022-03-07 6 | -------------------------------------------------------------------------------- /.changes/unreleased/Docs-20250811-160039.yaml: -------------------------------------------------------------------------------- 1 | kind: Docs 2 | body: Update help text for `mf query` options 3 | time: 2025-08-11T16:00:39.193958+02:00 4 | custom: 5 | Author: b-per 6 | Issue: "1815" 7 | -------------------------------------------------------------------------------- /dbt-metricflow/tests_dbt_metricflow/snapshots/test_cli.py/str/test_health_checks__result.txt: -------------------------------------------------------------------------------- 1 | test_name: test_health_checks 2 | test_filename: test_cli.py 3 | --- 4 | • ✅ SqlEngine.DUCKDB - SELECT 1: Success! 5 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251002-123407.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Remove `LinkableElementSet` 3 | time: 2025-10-02T12:34:07.522688-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1866" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251028-110712.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Remove assorted unused code 3 | time: 2025-10-28T11:07:12.368833-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1908" 7 | -------------------------------------------------------------------------------- /dbt-metricflow/tests_dbt_metricflow/snapshots/test_cli.py/str/test_get_dimension_values__result.txt: -------------------------------------------------------------------------------- 1 | test_name: test_get_dimension_values 2 | test_filename: test_cli.py 3 | --- 4 | • CA 5 | • FR 6 | • MX 7 | • US 8 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20250924-123604.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Remove `LegacyLinkableSpecResolver` 3 | time: 2025-09-24T12:36:04.048278-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1865" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251002-123447.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Rename classes for group-by items 3 | time: 2025-10-02T12:34:47.609972-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1870" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Fixes-20250916-121517.yaml: -------------------------------------------------------------------------------- 1 | kind: Fixes 2 | body: Don't error for lack of time dimensions in manfest 3 | time: 2025-09-16T12:15:17.278238-07:00 4 | custom: 5 | Author: courtneyholcomb 6 | Issue: "1848" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251002-123232.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Add workflow to check changelog files 3 | time: 2025-10-02T12:32:32.797437-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1847" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251002-131616.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Assorted fixes for `GroupByItemSetFilter` 3 | time: 2025-10-02T13:16:16.00412-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1873" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251008-115649.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Add `SemanticGraphNodeTypedCollection` 3 | time: 2025-10-08T11:56:49.809866-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1880" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251013-140929.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Rename `Metricflow*` -> `MetricFlow*` 3 | time: 2025-10-13T14:09:29.326515-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1904" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251030-110733.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Remove case to reproduce date-part bug 3 | time: 2025-10-30T11:07:33.406269-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1922" 7 | -------------------------------------------------------------------------------- /dbt-metricflow/tests_dbt_metricflow/snapshots/test_cli.py/str/test_list_entities__result.txt: -------------------------------------------------------------------------------- 1 | test_name: test_list_entities 2 | test_filename: test_cli.py 3 | --- 4 | • country 5 | • customer 6 | • id_order 7 | • transaction 8 | -------------------------------------------------------------------------------- /tests_metricflow/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantics.test_helpers.config_helpers import DirectoryPathAnchor 4 | 5 | TESTS_METRICFLOW_DIRECTORY_ANCHOR = DirectoryPathAnchor() 6 | -------------------------------------------------------------------------------- /.changes/unreleased/Dependencies-20251008-130706.yaml: -------------------------------------------------------------------------------- 1 | kind: Dependencies 2 | body: Update to `dbt-semantic-interfaces==0.9.4.dev0` 3 | time: 2025-10-08T13:07:06.525255-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1889" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Fixes-20251117-085411.yaml: -------------------------------------------------------------------------------- 1 | kind: Fixes 2 | body: Add dunder prefix to column aliases for simple-metric inputs 3 | time: 2025-11-17T08:54:11.838469-08:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1938" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251009-101142.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Remove deprecated measure-related classes 3 | time: 2025-10-09T10:11:42.568611-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1893" 7 | -------------------------------------------------------------------------------- /dbt-metricflow/dbt_metricflow/cli/mf_tutorial_project/dbt_project.yml: -------------------------------------------------------------------------------- 1 | name: mf_tutorial_project 2 | version: 1.0.0 3 | config-version: 2 4 | 5 | profile: mf_tutorial 6 | 7 | model-paths: ["models"] 8 | seed-paths: ["seeds"] 9 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251028-113955.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Move helper / utility methods to `toolkit` module 3 | time: 2025-10-28T11:39:55.38101-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1909" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251029-145529.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Move semantic-graph modules out of `experimental` 3 | time: 2025-10-29T14:55:29.241776-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1921" 7 | -------------------------------------------------------------------------------- /dbt-metricflow/dbt_metricflow/cli/sample_models/project_configuration.yaml: -------------------------------------------------------------------------------- 1 | project_configuration: 2 | time_spine_table_configurations: 3 | - location: $system_schema.mf_time_spine 4 | column_name: ds 5 | grain: day 6 | -------------------------------------------------------------------------------- /tests_metricflow/fixtures/dbt_projects/metricflow_testing/models/example/my_second_dbt_model.sql: -------------------------------------------------------------------------------- 1 | 2 | -- Use the `ref` function to select from other models 3 | 4 | select * 5 | from {{ ref('my_first_dbt_model') }} 6 | where id = 1 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Breaking Changes-20251008-115810.yaml: -------------------------------------------------------------------------------- 1 | kind: Breaking Changes 2 | body: Remove `MetricFlowEngine.get_measures_for_metrics` 3 | time: 2025-10-08T11:58:10.188775-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1881" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Fixes-20250918-070122.yaml: -------------------------------------------------------------------------------- 1 | kind: Fixes 2 | body: Pin to the latest non-dev release of dbt-semantic-interfaces. 3 | time: 2025-09-18T07:01:22.294658-07:00 4 | custom: 5 | Author: courtneyholcomb 6 | Issue: "1854" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Fixes-20251001-153436.yaml: -------------------------------------------------------------------------------- 1 | kind: Fixes 2 | body: Use node_relation to render time spine table with proper quoting. 3 | time: 2025-10-01T15:34:36.737372-07:00 4 | custom: 5 | Author: courtneyholcomb 6 | Issue: "1875" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251002-123044.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Add test for group-by items using the cyclic manifest 3 | time: 2025-10-02T12:30:44.181205-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1869" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251002-131522.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Consolidate measure / metric methods of `MetricLookup` 3 | time: 2025-10-02T13:15:22.654918-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1872" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251117-085231.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Consolidate alias SQL generation to `ComputeMetricsNode` 3 | time: 2025-11-17T08:52:31.35927-08:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1936" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251117-085319.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Remove `AggregateSimpleMetricInputsNode.alias_mapping` 3 | time: 2025-11-17T08:53:19.635548-08:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1937" 7 | -------------------------------------------------------------------------------- /dbt-metricflow/tests_dbt_metricflow/cli/demo_data_types_project_add_on/models/metrics.yml: -------------------------------------------------------------------------------- 1 | --- 2 | metrics: 3 | - name: demo_metric 4 | type: SIMPLE 5 | type_params: 6 | measure: demo_measure 7 | label: "Demo Metric" 8 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/tests/conftest.py: -------------------------------------------------------------------------------- 1 | # These imports are required to properly set up pytest fixtures. 2 | from __future__ import annotations 3 | 4 | from tests.fixtures.semantic_manifest_fixtures import * # noqa: F401, F403 5 | -------------------------------------------------------------------------------- /.changes/unreleased/Fixes-20251119-233621.yaml: -------------------------------------------------------------------------------- 1 | kind: Fixes 2 | body: Render simple-metric inputs without a dunder prefix for the `WHERE` filter 3 | time: 2025-11-19T23:36:21.068696-08:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1941" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Fixes-20251213-093421.yaml: -------------------------------------------------------------------------------- 1 | kind: Fixes 2 | body: Improve handling of invalid metrics in metadata methods of `MetricFlowEngine` 3 | time: 2025-12-13T09:34:21.571237-08:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1949" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251002-123542.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Consolidate measure-related operations into `MeasureLookup` 3 | time: 2025-10-02T12:35:42.003889-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1868" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251008-120225.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Update `metricflow` to migrate `measures -> simple metrics` 3 | time: 2025-10-08T12:02:25.007138-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1889" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251009-101045.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Remove measure-related functionality from `MetricLookup` 3 | time: 2025-10-09T10:10:45.233937-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1892" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251010-132641.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Remove `SimpleMetricInputSpec.non_additive_dimension_spec` 3 | time: 2025-10-10T13:26:41.503643-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1897" 7 | -------------------------------------------------------------------------------- /dbt-metricflow/dbt_metricflow/cli/constants.py: -------------------------------------------------------------------------------- 1 | """File containing constants used by CLI.""" 2 | 3 | # Display Setting Constants 4 | from __future__ import annotations 5 | 6 | MAX_LIST_OBJECT_ELEMENTS = 5 7 | DEFAULT_RESULT_DECIMAL_PLACES = 2 8 | -------------------------------------------------------------------------------- /dbt-metricflow/tests_dbt_metricflow/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantics.test_helpers.config_helpers import DirectoryPathAnchor 4 | 5 | TESTS_DBT_METRICFLOW_DIRECTORY_ANCHOR = DirectoryPathAnchor() 6 | -------------------------------------------------------------------------------- /local-data-warehouses/trino/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: "3.7" 2 | 3 | services: 4 | trino: 5 | container_name: trino 6 | image: "trinodb/trino" 7 | expose: 8 | - "8080" 9 | ports: 10 | - "8080:8080" 11 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/sql/sql_column_type.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import datetime 4 | from typing import Union 5 | 6 | SqlColumnType = Union[str, int, float, datetime.datetime, datetime.date, bool] 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20250924-123536.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Add tests for the filtering of `AnnotatedSpecLinkableElementSet` 3 | time: 2025-09-24T12:35:36.884127-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1864" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251002-122925.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Consolidate measure / metric methods of `GroupByItemSetResolver` 3 | time: 2025-10-02T12:29:25.789492-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1871" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251009-125205.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Copy dbt-semantic-interfaces into the MetricFlow repo. 3 | time: 2025-10-09T12:52:05.713867-07:00 4 | custom: 5 | Author: courtneyholcomb 6 | Issue: "1895" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251010-132547.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Mark tests from `test_dataflow_to_sql_plan.py` as DuckDB-Only 3 | time: 2025-10-10T13:25:47.926875-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1896" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251010-132817.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Renames for the `measures -> simple metrics` migration - Part 1 3 | time: 2025-10-10T13:28:17.411613-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1898" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251013-140823.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Renames for the `measures -> simple metrics` migration - Part 2 3 | time: 2025-10-13T14:08:23.664574-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1902" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251013-140859.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Renames for the `measures -> simple metrics` migration - Part 3 3 | time: 2025-10-13T14:08:59.631665-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1903" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Fixes-20251015-143859.yaml: -------------------------------------------------------------------------------- 1 | kind: Fixes 2 | body: Properly apply time constraints on agg time dimensions for cumulative metrics. 3 | time: 2025-10-15T14:38:59.627076-04:00 4 | custom: 5 | Author: courtneyholcomb 6 | Issue: "1910" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Fixes-20251023-154834.yaml: -------------------------------------------------------------------------------- 1 | kind: Fixes 2 | body: Fixes a bug causing errors for join_to_timespine metrics queried with date part. 3 | time: 2025-10-23T15:48:34.954658-07:00 4 | custom: 5 | Author: courtneyholcomb 6 | Issue: "1919" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251008-120045.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Update `metricflow_semantics` to migrate `measures -> simple metrics` 3 | time: 2025-10-08T12:00:45.291422-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1882" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251008-150031.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Add a test for `MetricLookup. get_aggregation_time_dimension_specs()` 3 | time: 2025-10-08T15:00:31.500705-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1890" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251009-101212.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Update simple-metric generation in the synthetic manifest generator 3 | time: 2025-10-09T10:12:12.538832-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1894" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251008-150124.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Update SQL engine snapshots for the `measures -> simple metrics` migration 3 | time: 2025-10-08T15:01:24.083877-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1891" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251029-140033.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Update Cursor rules file to include linting + loading of additional rules 3 | time: 2025-10-29T14:00:33.96369-07:00 4 | custom: 5 | Author: plypaul 6 | Issue: "1920" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Dependencies-20251024-132913.yaml: -------------------------------------------------------------------------------- 1 | kind: Dependencies 2 | body: Bumping upperbound range for dbt-semantic-interfaces in metricflow-semantics 3 | time: 2025-10-24T13:29:13.372292-04:00 4 | custom: 5 | Author: WilliamDee 6 | Issue: None 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251204-125847.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Filter out unneeded specs in dataflow plan before applying where filter. 3 | time: 2025-12-04T12:58:47.462903-08:00 4 | custom: 5 | Author: courtneyholcomb 6 | Issue: "1944" 7 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantics.test_helpers.config_helpers import DirectoryPathAnchor 4 | 5 | TESTS_METRICFLOW_SEMANTICS_DIRECTORY_ANCHOR = DirectoryPathAnchor() 6 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/snapshots/test_spec_lookup.py/str/test_filter_spec_resolution__no_metrics__result.txt: -------------------------------------------------------------------------------- 1 | test_name: test_filter_spec_resolution[no_metrics] 2 | test_filename: test_spec_lookup.py 3 | --- 4 | FilterSpecResolutionLookUp() 5 | -------------------------------------------------------------------------------- /.changes/unreleased/Dependencies-20251006-144510.yaml: -------------------------------------------------------------------------------- 1 | kind: Dependencies 2 | body: Update requirement for dependency `more-itertools` to include newest version 3 | time: 2025-10-06T14:45:10.7005413+02:00 4 | custom: 5 | Author: MatthijsKok 6 | Issue: "1879" 7 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/time/time_constants.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | # Python formatting string to use for converting datetime to ISO8601 4 | ISO8601_PYTHON_FORMAT = "%Y-%m-%d" 5 | ISO8601_PYTHON_TS_FORMAT = "%Y-%m-%d %H:%M:%S" 6 | -------------------------------------------------------------------------------- /local-data-warehouses/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Local Data Warehouse Setup 3 | # 4 | 5 | .PHONY: postgresql 6 | postgresql: 7 | docker-compose -f postgresql/docker-compose.yaml up 8 | 9 | .PHONY: trino 10 | trino: 11 | docker-compose -f trino/docker-compose.yaml up 12 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_query_output.py/str/DuckDB/test_scd_filter_without_metric_time__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_scd_filter_without_metric_time 2 | test_filename: test_query_output.py 3 | --- 4 | family_bookings 5 | ----------------- 6 | 120 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Breaking Changes-20251014-103322.yaml: -------------------------------------------------------------------------------- 1 | kind: Breaking Changes 2 | body: License Change - Version 0.209.0 and greater is covered by the Apache 2.0 license. 3 | time: 2025-10-14T10:33:22.986318-04:00 4 | custom: 5 | Author: courtneyholcomb 6 | Issue: "1905" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Features-20251002-171248.yaml: -------------------------------------------------------------------------------- 1 | kind: Features 2 | body: Add new transformations to production from dsi that produce metrics from old-style measures. 3 | time: 2025-10-02T17:12:48.436607-07:00 4 | custom: 5 | Author: theyostalservice 6 | Issue: "387" 7 | -------------------------------------------------------------------------------- /.changes/unreleased/Fixes-20251216-092605.yaml: -------------------------------------------------------------------------------- 1 | kind: Fixes 2 | body: Fixes an issue where metric-level YAML filters are not applied for cumulative 3 | & conversion metrics. 4 | time: 2025-12-16T09:26:05.962328-08:00 5 | custom: 6 | Author: courtneyholcomb 7 | Issue: "1950" 8 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantics.test_helpers.config_helpers import DirectoryPathAnchor 4 | 5 | SEMANTIC_MANIFEST_YAMLS_PATH_ANCHOR = DirectoryPathAnchor() 6 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/scd_manifest/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantics.test_helpers.config_helpers import DirectoryPathAnchor 4 | 5 | SCD_MANIFEST_ANCHOR = DirectoryPathAnchor() 6 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/sg_02_single_join/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantics.test_helpers.config_helpers import DirectoryPathAnchor 4 | 5 | SG_02_SINGLE_JOIN = DirectoryPathAnchor() 6 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/non_sm_manifest/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantics.test_helpers.config_helpers import DirectoryPathAnchor 4 | 5 | NON_SM_MANIFEST_ANCHOR = DirectoryPathAnchor() 6 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/simple_manifest/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantics.test_helpers.config_helpers import DirectoryPathAnchor 4 | 5 | SIMPLE_MANIFEST_ANCHOR = DirectoryPathAnchor() 6 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/DuckDB/test_render_limit__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_limit 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: DuckDB 4 | --- 5 | -- test0 6 | SELECT 7 | a.bookings 8 | FROM demo.fct_bookings a 9 | LIMIT 1 10 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Trino/test_render_limit__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_limit 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: Trino 4 | --- 5 | -- test0 6 | SELECT 7 | a.bookings 8 | FROM demo.fct_bookings a 9 | LIMIT 1 10 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/sg_00_minimal_manifest/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantics.test_helpers.config_helpers import DirectoryPathAnchor 4 | 5 | SG_00_MINIMAL_MANIFEST = DirectoryPathAnchor() 6 | -------------------------------------------------------------------------------- /requirements-files/requirements.txt: -------------------------------------------------------------------------------- 1 | Jinja2>=3.1.6, <3.7.0 2 | # bumping to 0.9.3 will cause test failures, so pinning to dev2 until fixed 3 | dbt-semantic-interfaces==0.9.4.dev2 4 | more-itertools>=10.0.0, <11.0.0 5 | pydantic>=1.10.0, <3.0 6 | tabulate>=0.8.9 7 | typing_extensions>=4.4, <5.0 8 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/BigQuery/test_render_limit__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_limit 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: BigQuery 4 | --- 5 | -- test0 6 | SELECT 7 | a.bookings 8 | FROM demo.fct_bookings a 9 | LIMIT 1 10 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Postgres/test_render_limit__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_limit 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: Postgres 4 | --- 5 | -- test0 6 | SELECT 7 | a.bookings 8 | FROM demo.fct_bookings a 9 | LIMIT 1 10 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Redshift/test_render_limit__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_limit 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: Redshift 4 | --- 5 | -- test0 6 | SELECT 7 | a.bookings 8 | FROM demo.fct_bookings a 9 | LIMIT 1 10 | -------------------------------------------------------------------------------- /dbt-metricflow/dbt_metricflow/cli/sample_dbt_models/sources.yml: -------------------------------------------------------------------------------- 1 | sources: 2 | - name: tutorial 3 | schema: $system_schema 4 | description: Data sets for running mf tutorial 5 | tables: 6 | - name: transactions_seed 7 | - name: customers_seed 8 | - name: countries_seed 9 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/cyclic_join_manifest/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantics.test_helpers.config_helpers import DirectoryPathAnchor 4 | 5 | CYCLIC_JOIN_MANIFEST_ANCHOR = DirectoryPathAnchor() 6 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/join_types_manifest/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantics.test_helpers.config_helpers import DirectoryPathAnchor 4 | 5 | JOIN_TYPES_MANIFEST_ANCHOR = DirectoryPathAnchor() 6 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/sg_05_derived_metric/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantics.test_helpers.config_helpers import DirectoryPathAnchor 4 | 5 | SG_05_DERIVED_METRIC_MANIFEST = DirectoryPathAnchor() 6 | -------------------------------------------------------------------------------- /metricflow/sql/render/rendering_constants.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | 4 | class SqlRenderingConstants: 5 | """Constants used for rendering SQL.""" 6 | 7 | # The indentation for SQL e.g. 8 | # SELECT 9 | # foo 10 | # , bar 11 | INDENT = " " 12 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Databricks/test_render_limit__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_limit 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: Databricks 4 | --- 5 | -- test0 6 | SELECT 7 | a.bookings 8 | FROM demo.fct_bookings a 9 | LIMIT 1 10 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Snowflake/test_render_limit__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_limit 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: Snowflake 4 | --- 5 | -- test0 6 | SELECT 7 | a.bookings 8 | FROM demo.fct_bookings a 9 | LIMIT 1 10 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251003-080025.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Bump dependence on dbt-semantic-interfaces to 0.9.3.dev4 to get newest transformations code. 3 | time: 2025-10-03T08:00:25.705141-07:00 4 | custom: 5 | Author: theyostalservice courtneyholcomb 6 | Issue: "387" 7 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/config_linter_manifest/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantics.test_helpers.config_helpers import DirectoryPathAnchor 4 | 5 | CONFIG_LINTER_MANIFEST_ANCHOR = DirectoryPathAnchor() 6 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/extended_date_manifest/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantics.test_helpers.config_helpers import DirectoryPathAnchor 4 | 5 | EXTENDED_DATE_MANIFEST_ANCHOR = DirectoryPathAnchor() 6 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/multi_hop_join_manifest/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantics.test_helpers.config_helpers import DirectoryPathAnchor 4 | 5 | MULTI_HOP_JOIN_MANIFEST_ANCHOR = DirectoryPathAnchor() 6 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/name_edge_case_manifest/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantics.test_helpers.config_helpers import DirectoryPathAnchor 4 | 5 | NAME_EDGE_CASE_MANIFEST_ANCHOR = DirectoryPathAnchor() 6 | -------------------------------------------------------------------------------- /dbt-metricflow/tests_dbt_metricflow/cli/demo_data_types_project_add_on/seeds/properties.yml: -------------------------------------------------------------------------------- 1 | seeds: 2 | - name: demo_data_types_seed 3 | config: 4 | column_types: 5 | str_value: VARCHAR 6 | int_value: BIGINT 7 | float_value: FLOAT 8 | decimal_value: DECIMAL(38,19) 9 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/data_warehouse_validation_manifest/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantics.test_helpers.config_helpers import DirectoryPathAnchor 4 | 5 | DW_VALIDATION_MANIFEST_ANCHOR = DirectoryPathAnchor() 6 | -------------------------------------------------------------------------------- /tests_metricflow/fixtures/source_table_snapshots/data_warehouse_validation_model/fct_animals.yaml: -------------------------------------------------------------------------------- 1 | table_snapshot: 2 | table_name: fct_animals 3 | column_definitions: 4 | - name: is_dog 5 | type: BOOLEAN 6 | - name: ds 7 | type: TIME 8 | rows: 9 | - ["True", "2022-06-01"] 10 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/DuckDB/test_render_where__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_where 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: DuckDB 4 | --- 5 | -- test0 6 | SELECT 7 | a.booking_value 8 | FROM demo.fct_bookings a 9 | WHERE a.booking_value > 100 10 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Trino/test_render_where__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_where 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: Trino 4 | --- 5 | -- test0 6 | SELECT 7 | a.booking_value 8 | FROM demo.fct_bookings a 9 | WHERE a.booking_value > 100 10 | -------------------------------------------------------------------------------- /.changes/unreleased/Fixes-20251015-143827.yaml: -------------------------------------------------------------------------------- 1 | kind: Fixes 2 | body: Fixes a bug related to leaving out metric values in offset metrics, specifically 3 | if the queried grain is smaller than the offset grain. 4 | time: 2025-10-15T14:38:27.163025-04:00 5 | custom: 6 | Author: courtneyholcomb 7 | Issue: "1910" 8 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/ambiguous_resolution_manifest/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantics.test_helpers.config_helpers import DirectoryPathAnchor 4 | 5 | AMBIGUOUS_RESOLUTION_MANIFEST_ANCHOR = DirectoryPathAnchor() 6 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/simple_multi_hop_join_manifest/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantics.test_helpers.config_helpers import DirectoryPathAnchor 4 | 5 | SIMPLE_MULTI_HOP_JOIN_MANIFEST_ANCHOR = DirectoryPathAnchor() 6 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/BigQuery/test_render_where__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_where 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: BigQuery 4 | --- 5 | -- test0 6 | SELECT 7 | a.booking_value 8 | FROM demo.fct_bookings a 9 | WHERE a.booking_value > 100 10 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Postgres/test_render_where__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_where 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: Postgres 4 | --- 5 | -- test0 6 | SELECT 7 | a.booking_value 8 | FROM demo.fct_bookings a 9 | WHERE a.booking_value > 100 10 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Redshift/test_render_where__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_where 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: Redshift 4 | --- 5 | -- test0 6 | SELECT 7 | a.booking_value 8 | FROM demo.fct_bookings a 9 | WHERE a.booking_value > 100 10 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/multi_hop_join_manifest/metrics.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | metric: 3 | name: paraguayan_customers 4 | type: SIMPLE 5 | type_params: 6 | measure: customers_with_other_data 7 | filter: | 8 | {{ Dimension('customer_id__country') }} = 'paraguay' 9 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Databricks/test_render_where__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_where 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: Databricks 4 | --- 5 | -- test0 6 | SELECT 7 | a.booking_value 8 | FROM demo.fct_bookings a 9 | WHERE a.booking_value > 100 10 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Snowflake/test_render_where__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_where 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: Snowflake 4 | --- 5 | -- test0 6 | SELECT 7 | a.booking_value 8 | FROM demo.fct_bookings a 9 | WHERE a.booking_value > 100 10 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/partitioned_multi_hop_join_manifest/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantics.test_helpers.config_helpers import DirectoryPathAnchor 4 | 5 | PARTITIONED_MULTI_HOP_JOIN_MANIFEST_ANCHOR = DirectoryPathAnchor() 6 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/extended_date_manifest/metrics/bookings_cumulative.yaml: -------------------------------------------------------------------------------- 1 | metric: 2 | name: "weekly_bookers" 3 | description: "weekly_bookers" 4 | type: cumulative 5 | type_params: 6 | measure: bookings 7 | cumulative_type_params: 8 | window: 7 days 9 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/partitioned_multi_hop_join_manifest/metrics.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | metric: 3 | name: paraguayan_customers 4 | type: SIMPLE 5 | type_params: 6 | measure: customers_with_other_data 7 | filter: | 8 | {{ Dimension('customer_id__country') }} = 'paraguay' 9 | -------------------------------------------------------------------------------- /dbt-metricflow/dbt_metricflow/cli/cli_string.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | 4 | class CLIString: 5 | """Contains CLI strings that benefit from centralization.""" 6 | 7 | LOG_FILE_PREFIX = "Log File:" 8 | ARTIFACT_PATH = "Artifact Path:" 9 | ARTIFACT_MODIFIED_TIME = "Artifact Modified Time:" 10 | -------------------------------------------------------------------------------- /tests_metricflow/fixtures/source_table_snapshots/simple_multi_hop_join_manifest/entity_2_measure_table.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | table_snapshot: 3 | table_name: entity_2_measure_table 4 | column_definitions: 5 | - name: entity_2 6 | type: STRING 7 | - name: ds 8 | type: TIME 9 | rows: 10 | - ["E2_0", "2020-01-01"] 11 | -------------------------------------------------------------------------------- /dbt-metricflow/tests_dbt_metricflow/snapshots/test_cli.py/str/test_csv__result.txt: -------------------------------------------------------------------------------- 1 | test_name: test_csv 2 | test_filename: test_cli.py 3 | docstring: 4 | Tests writing the results of a query to a file. 5 | expectation_description: 6 | A CSV file containing the values for 2 metrics. 7 | --- 8 | transactions,quick_buy_transactions 9 | 50,10 10 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/DuckDB/test_render_order_by__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_order_by 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: DuckDB 4 | --- 5 | -- test0 6 | SELECT 7 | a.booking_value 8 | , a.bookings 9 | FROM demo.fct_bookings a 10 | ORDER BY a.booking_value, a.bookings DESC 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Trino/test_render_order_by__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_order_by 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: Trino 4 | --- 5 | -- test0 6 | SELECT 7 | a.booking_value 8 | , a.bookings 9 | FROM demo.fct_bookings a 10 | ORDER BY a.booking_value, a.bookings DESC 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/BigQuery/test_render_order_by__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_order_by 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: BigQuery 4 | --- 5 | -- test0 6 | SELECT 7 | a.booking_value 8 | , a.bookings 9 | FROM demo.fct_bookings a 10 | ORDER BY a.booking_value, a.bookings DESC 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Postgres/test_render_order_by__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_order_by 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: Postgres 4 | --- 5 | -- test0 6 | SELECT 7 | a.booking_value 8 | , a.bookings 9 | FROM demo.fct_bookings a 10 | ORDER BY a.booking_value, a.bookings DESC 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Redshift/test_render_order_by__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_order_by 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: Redshift 4 | --- 5 | -- test0 6 | SELECT 7 | a.booking_value 8 | , a.bookings 9 | FROM demo.fct_bookings a 10 | ORDER BY a.booking_value, a.bookings DESC 11 | -------------------------------------------------------------------------------- /tests_metricflow/fixtures/source_table_snapshots/simple_multi_hop_join_manifest/entity_1_to_entity_0_mapping_table.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | table_snapshot: 3 | table_name: entity_1_to_entity_0_table 4 | column_definitions: 5 | - name: entity_1 6 | type: STRING 7 | - name: entity_0 8 | type: STRING 9 | rows: 10 | - ["E1_0", "E0_0"] 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Databricks/test_render_order_by__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_order_by 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: Databricks 4 | --- 5 | -- test0 6 | SELECT 7 | a.booking_value 8 | , a.bookings 9 | FROM demo.fct_bookings a 10 | ORDER BY a.booking_value, a.bookings DESC 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Snowflake/test_render_order_by__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_order_by 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: Snowflake 4 | --- 5 | -- test0 6 | SELECT 7 | a.booking_value 8 | , a.bookings 9 | FROM demo.fct_bookings a 10 | ORDER BY a.booking_value, a.bookings DESC 11 | -------------------------------------------------------------------------------- /dbt-metricflow/tests_dbt_metricflow/snapshots/test_cli.py/str/test_list_dimensions__result.txt: -------------------------------------------------------------------------------- 1 | test_name: test_list_dimensions 2 | test_filename: test_cli.py 3 | --- 4 | • customer__country__region 5 | • customer__customer_country 6 | • customer__ds 7 | • metric_time 8 | • transaction__ds 9 | • transaction__is_large 10 | • transaction__quick_buy_transaction 11 | -------------------------------------------------------------------------------- /tests_metricflow/fixtures/source_table_snapshots/simple_multi_hop_join_manifest/entity_2_to_entity_0_mapping_table.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | table_snapshot: 3 | table_name: entity_2_to_entity_0_mapping_table 4 | column_definitions: 5 | - name: entity_2 6 | type: STRING 7 | - name: entity_0 8 | type: STRING 9 | rows: 10 | - ["E2_0", "E0_1"] 11 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/metricflow_semantic_interfaces/transformations/boolean_measure.py: -------------------------------------------------------------------------------- 1 | # export retained to maintain backwards compatibility until we deprecate measures fully 2 | from __future__ import annotations 3 | 4 | from metricflow_semantic_interfaces.transformations.boolean_aggregations import ( # noqa: F401 5 | BooleanMeasureAggregationRule, 6 | ) 7 | -------------------------------------------------------------------------------- /requirements-files/dev-env-requirements.txt: -------------------------------------------------------------------------------- 1 | dbt-core>=1.10.4, <1.11.0 2 | dbt-duckdb>=1.8.0, <1.9.0 3 | # Excluding 1.2.1 due to window functions returning incorrect results: 4 | # https://github.com/duckdb/duckdb/issues/16617 5 | # Version 1.4.0 seems to have issues as well, so pinning to <1.4.0 until those are resolved. 6 | duckdb !=1.2.1, <1.4.0 7 | tomli >=2.3.0, <3 8 | -------------------------------------------------------------------------------- /tests_metricflow/fixtures/source_table_snapshots/simple_multi_hop_join_manifest/entity_0_dimension_table.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | table_snapshot: 3 | table_name: entity_0_dimension_source 4 | column_definitions: 5 | - name: entity_0 6 | type: STRING 7 | - name: country 8 | type: STRING 9 | rows: 10 | - ["E0_0", "us"] 11 | - ["E0_1", "ca"] 12 | -------------------------------------------------------------------------------- /tests_metricflow/fixtures/source_table_snapshots/simple_multi_hop_join_manifest/entity_1_dimension_table.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | table_snapshot: 3 | table_name: entity_1_dimension_source 4 | column_definitions: 5 | - name: entity_1 6 | type: STRING 7 | - name: country 8 | type: STRING 9 | rows: 10 | - ["E0_2", "us"] 11 | - ["E0_3", "ca"] 12 | -------------------------------------------------------------------------------- /dbt-metricflow/tests_dbt_metricflow/snapshots/test_cli.py/str/test_list_saved_queries__result.txt: -------------------------------------------------------------------------------- 1 | test_name: test_list_saved_queries 2 | test_filename: test_cli.py 3 | --- 4 | The list below shows saved queries with their descriptions: 5 | • core_transaction_metrics: Important transaction metrics. 6 | • cumulative_transaction_metrics: Cumulative metrics related to transactions. 7 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/snapshots/test_snapshot.py/str/test_expectation_description__result.txt: -------------------------------------------------------------------------------- 1 | test_name: test_expectation_description 2 | test_filename: test_snapshot.py 3 | docstring: 4 | Tests having a description of the expectation in a snapshot. 5 | expectation_description: 6 | The snapshot should show the 2 as the result. 7 | --- 8 | 1 + 1 = 2 9 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/DuckDB/test_render_create_table_as__create_view_as.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_create_table_as 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: DuckDB 4 | --- 5 | CREATE VIEW schema_name.table_name AS ( 6 | -- select_0 7 | SELECT 8 | a.bookings 9 | FROM demo.fct_bookings a 10 | LIMIT 1 11 | ) 12 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Trino/test_render_create_table_as__create_table_as.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_create_table_as 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: Trino 4 | --- 5 | CREATE TABLE schema_name.table_name AS ( 6 | -- select_0 7 | SELECT 8 | a.bookings 9 | FROM demo.fct_bookings a 10 | LIMIT 1 11 | ) 12 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Trino/test_render_create_table_as__create_view_as.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_create_table_as 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: Trino 4 | --- 5 | CREATE VIEW schema_name.table_name AS ( 6 | -- select_0 7 | SELECT 8 | a.bookings 9 | FROM demo.fct_bookings a 10 | LIMIT 1 11 | ) 12 | -------------------------------------------------------------------------------- /dbt-metricflow/tests_dbt_metricflow/cli/demo_data_types_project_add_on/__init__.py: -------------------------------------------------------------------------------- 1 | """Directory containing files that can be added to a dbt project to query dimension of various data types.""" 2 | from __future__ import annotations 3 | 4 | from metricflow_semantics.test_helpers.config_helpers import DirectoryPathAnchor 5 | 6 | DEMO_DATA_TYPES_ADD_ON_PATH_ANCHOR = DirectoryPathAnchor() 7 | -------------------------------------------------------------------------------- /local-data-warehouses/postgresql/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: "3.7" 2 | 3 | services: 4 | postgres: 5 | container_name: postgres 6 | image: postgres 7 | expose: 8 | - "5432" 9 | ports: 10 | - "5432:5432" 11 | environment: 12 | POSTGRES_USER: "metricflow" 13 | POSTGRES_PASSWORD: "metricflowing" 14 | POSTGRES_DB: "metricflow" 15 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/specs/conftest.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from dbt_semantic_interfaces.references import MetricReference 4 | from metricflow_semantics.query.group_by_item.filter_spec_resolution.filter_location import WhereFilterLocation 5 | 6 | EXAMPLE_FILTER_LOCATION = WhereFilterLocation.for_metric(MetricReference("example_metric")) 7 | -------------------------------------------------------------------------------- /tests_metricflow/fixtures/source_table_snapshots/simple_model/dim_companies.yaml: -------------------------------------------------------------------------------- 1 | table_snapshot: 2 | table_name: dim_companies 3 | column_definitions: 4 | - name: company_id 5 | type: STRING 6 | - name: company_name 7 | type: STRING 8 | - name: user_id 9 | type: STRING 10 | rows: 11 | - ["cpid_0", "MD Vacation Rentals LLC", "u0003154"] 12 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/BigQuery/test_render_create_table_as__create_table_as.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_create_table_as 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: BigQuery 4 | --- 5 | CREATE TABLE schema_name.table_name AS ( 6 | -- select_0 7 | SELECT 8 | a.bookings 9 | FROM demo.fct_bookings a 10 | LIMIT 1 11 | ) 12 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/BigQuery/test_render_create_table_as__create_view_as.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_create_table_as 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: BigQuery 4 | --- 5 | CREATE VIEW schema_name.table_name AS ( 6 | -- select_0 7 | SELECT 8 | a.bookings 9 | FROM demo.fct_bookings a 10 | LIMIT 1 11 | ) 12 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/DuckDB/test_render_create_table_as__create_table_as.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_create_table_as 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: DuckDB 4 | --- 5 | CREATE TABLE schema_name.table_name AS ( 6 | -- select_0 7 | SELECT 8 | a.bookings 9 | FROM demo.fct_bookings a 10 | LIMIT 1 11 | ) 12 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Postgres/test_render_create_table_as__create_table_as.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_create_table_as 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: Postgres 4 | --- 5 | CREATE TABLE schema_name.table_name AS ( 6 | -- select_0 7 | SELECT 8 | a.bookings 9 | FROM demo.fct_bookings a 10 | LIMIT 1 11 | ) 12 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Postgres/test_render_create_table_as__create_view_as.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_create_table_as 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: Postgres 4 | --- 5 | CREATE VIEW schema_name.table_name AS ( 6 | -- select_0 7 | SELECT 8 | a.bookings 9 | FROM demo.fct_bookings a 10 | LIMIT 1 11 | ) 12 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Redshift/test_render_create_table_as__create_table_as.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_create_table_as 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: Redshift 4 | --- 5 | CREATE TABLE schema_name.table_name AS ( 6 | -- select_0 7 | SELECT 8 | a.bookings 9 | FROM demo.fct_bookings a 10 | LIMIT 1 11 | ) 12 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Redshift/test_render_create_table_as__create_view_as.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_create_table_as 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: Redshift 4 | --- 5 | CREATE VIEW schema_name.table_name AS ( 6 | -- select_0 7 | SELECT 8 | a.bookings 9 | FROM demo.fct_bookings a 10 | LIMIT 1 11 | ) 12 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Snowflake/test_render_create_table_as__create_view_as.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_create_table_as 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: Snowflake 4 | --- 5 | CREATE VIEW schema_name.table_name AS ( 6 | -- select_0 7 | SELECT 8 | a.bookings 9 | FROM demo.fct_bookings a 10 | LIMIT 1 11 | ) 12 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Databricks/test_render_create_table_as__create_table_as.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_create_table_as 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: Databricks 4 | --- 5 | CREATE TABLE schema_name.table_name AS ( 6 | -- select_0 7 | SELECT 8 | a.bookings 9 | FROM demo.fct_bookings a 10 | LIMIT 1 11 | ) 12 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Databricks/test_render_create_table_as__create_view_as.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_create_table_as 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: Databricks 4 | --- 5 | CREATE VIEW schema_name.table_name AS ( 6 | -- select_0 7 | SELECT 8 | a.bookings 9 | FROM demo.fct_bookings a 10 | LIMIT 1 11 | ) 12 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Snowflake/test_render_create_table_as__create_table_as.sql: -------------------------------------------------------------------------------- 1 | test_name: test_render_create_table_as 2 | test_filename: test_sql_plan_render.py 3 | sql_engine: Snowflake 4 | --- 5 | CREATE TABLE schema_name.table_name AS ( 6 | -- select_0 7 | SELECT 8 | a.bookings 9 | FROM demo.fct_bookings a 10 | LIMIT 1 11 | ) 12 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Trino/test_generate_uuid__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_generate_uuid 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the generate uuid expression in a query. 5 | sql_engine: Trino 6 | --- 7 | -- Test Generate UUID Expression 8 | SELECT 9 | uuid() AS uuid 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/metricflow_semantic_interfaces/type_enums/export_destination_type.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantic_interfaces.enum_extension import ExtendedEnum 4 | 5 | 6 | class ExportDestinationType(ExtendedEnum): 7 | """Types of destinations that exports can be written to.""" 8 | 9 | TABLE = "table" 10 | VIEW = "view" 11 | -------------------------------------------------------------------------------- /tests_metricflow/fixtures/source_table_snapshots/simple_multi_hop_join_manifest/entity_0_measure_table.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | table_snapshot: 3 | table_name: entity_0_measure_table 4 | column_definitions: 5 | - name: entity_0_measure 6 | type: INT 7 | - name: entity_0 8 | type: STRING 9 | - name: ds 10 | type: TIME 11 | rows: 12 | - ["0", "E0_0", "2020-01-01"] 13 | -------------------------------------------------------------------------------- /tests_metricflow/fixtures/source_table_snapshots/simple_multi_hop_join_manifest/entity_1_measure_table.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | table_snapshot: 3 | table_name: entity_1_measure_table 4 | column_definitions: 5 | - name: entity_1_measure 6 | type: INT 7 | - name: entity_1 8 | type: STRING 9 | - name: ds 10 | type: TIME 11 | rows: 12 | - ["1", "E1_0", "2020-01-01"] 13 | -------------------------------------------------------------------------------- /metricflow/engine/time_source.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import datetime as dt 4 | 5 | from metricflow_semantics.time.time_source import TimeSource 6 | 7 | 8 | class ServerTimeSource(TimeSource): 9 | """A time source that represents the current datetime in UTC.""" 10 | 11 | def get_time(self) -> dt.datetime: # noqa: D102 12 | return dt.datetime.utcnow() 13 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Databricks/test_generate_uuid__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_generate_uuid 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the generate uuid expression in a query. 5 | sql_engine: Databricks 6 | --- 7 | -- Test Generate UUID Expression 8 | SELECT 9 | UUID() AS uuid 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/metricflow_semantic_interfaces/type_enums/period_agg.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantic_interfaces.enum_extension import ExtendedEnum 4 | 5 | 6 | class PeriodAggregation(ExtendedEnum): 7 | """Options for how to aggregate across a time period.""" 8 | 9 | FIRST = "first" 10 | LAST = "last" 11 | AVERAGE = "average" 12 | -------------------------------------------------------------------------------- /tests_metricflow/fixtures/source_table_snapshots/simple_model/dim_lux_listing_id_mapping.yaml: -------------------------------------------------------------------------------- 1 | table_snapshot: 2 | table_name: dim_lux_listing_id_mapping 3 | column_definitions: 4 | - name: listing_id 5 | type: STRING 6 | - name: lux_listing_id 7 | type: STRING 8 | rows: 9 | - ["l2718281", "ll_002"] 10 | - ["l3141592", "ll_001"] 11 | - ["l5948301", "LUX_TEST_ID"] 12 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/BigQuery/test_generate_uuid__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_generate_uuid 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the generate uuid expression in a query. 5 | sql_engine: BigQuery 6 | --- 7 | -- Test Generate UUID Expression 8 | SELECT 9 | GENERATE_UUID() AS uuid 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/DuckDB/test_generate_uuid__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_generate_uuid 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the generate uuid expression in a query. 5 | sql_engine: DuckDB 6 | --- 7 | -- Test Generate UUID Expression 8 | SELECT 9 | GEN_RANDOM_UUID() AS uuid 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Postgres/test_generate_uuid__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_generate_uuid 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the generate uuid expression in a query. 5 | sql_engine: Postgres 6 | --- 7 | -- Test Generate UUID Expression 8 | SELECT 9 | GEN_RANDOM_UUID() AS uuid 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Snowflake/test_generate_uuid__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_generate_uuid 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the generate uuid expression in a query. 5 | sql_engine: Snowflake 6 | --- 7 | -- Test Generate UUID Expression 8 | SELECT 9 | UUID_STRING() AS uuid 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/snapshots/test_available_group_by_items.py/LinkableSpecSet/test_available_group_by_items__metrics_with_different_time_grains__set0.txt: -------------------------------------------------------------------------------- 1 | test_name: test_available_group_by_items[metrics_with_different_time_grains] 2 | test_filename: test_available_group_by_items.py 3 | --- 4 | ["TimeDimension('metric_time', 'year')", "TimeDimension('metric_time', date_part_name='year')"] 5 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/DuckDB/test_add_time_expr__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_add_time_expr 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the SqlAddTimeExpr in a query. 5 | sql_engine: DuckDB 6 | --- 7 | -- Test Add Time Expression 8 | SELECT 9 | '2020-01-01' + INTERVAL (1 * 3) month AS add_time 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Trino/test_add_time_expr__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_add_time_expr 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the SqlAddTimeExpr in a query. 5 | sql_engine: Trino 6 | --- 7 | -- Test Add Time Expression 8 | SELECT 9 | DATE_ADD('month', (1), '2020-01-01') AS add_time 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/DuckDB/test_component_rendering__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_component_rendering 2 | test_filename: test_sql_plan_render.py 3 | docstring: 4 | Checks that all components of SELECT query are rendered for the 0, 1, >1 component count cases. 5 | sql_engine: DuckDB 6 | --- 7 | -- test0 8 | SELECT 9 | SUM(1) AS bookings 10 | FROM demo.fct_bookings a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Trino/test_component_rendering__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_component_rendering 2 | test_filename: test_sql_plan_render.py 3 | docstring: 4 | Checks that all components of SELECT query are rendered for the 0, 1, >1 component count cases. 5 | sql_engine: Trino 6 | --- 7 | -- test0 8 | SELECT 9 | SUM(1) AS bookings 10 | FROM demo.fct_bookings a 11 | -------------------------------------------------------------------------------- /.changes/unreleased/Under the Hood-20251212-122315.yaml: -------------------------------------------------------------------------------- 1 | kind: Under the Hood 2 | body: Move CLI tests to dbt-metricflow package. Developers will need to run `make test-include-slow` to execute CLI tests locally, and will need to run `hatch -v run dev-env:pre-commit clean` to pick up the relevant config changes for linting. 3 | time: 2025-12-12T12:23:15.386854-08:00 4 | custom: 5 | Author: tlento 6 | Issue: "1948" 7 | -------------------------------------------------------------------------------- /dbt-metricflow/dbt_metricflow/cli/sample_dbt_models/sample_models/countries.yml: -------------------------------------------------------------------------------- 1 | semantic_models: 2 | - name: countries 3 | description: Regions mapped to countries. 4 | model: ref('countries') 5 | entities: 6 | - name: country 7 | type: primary 8 | dimensions: 9 | - name: region 10 | description: The region associated with the country. 11 | type: categorical 12 | -------------------------------------------------------------------------------- /dbt-metricflow/tests_dbt_metricflow/snapshots/test_isolated_command_runner.py/str/test_isolated_query__result.txt: -------------------------------------------------------------------------------- 1 | test_name: test_isolated_query 2 | test_filename: test_isolated_command_runner.py 3 | docstring: 4 | Tests running an MF query using the isolated runner. 5 | expectation_description: 6 | A table showing the `transactions` metric. 7 | --- 8 | transactions 9 | -------------- 10 | 50 11 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/extended_date_manifest/metrics/bookings_monthly_cumulative.yaml: -------------------------------------------------------------------------------- 1 | metric: 2 | name: trailing_3_months_bookings 3 | description: Prior 3 months' bookings. Tests a cumulative metric with non-day granularity. 4 | type: cumulative 5 | type_params: 6 | measure: bookings_monthly 7 | cumulative_type_params: 8 | window: 3 month 9 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Redshift/test_add_time_expr__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_add_time_expr 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the SqlAddTimeExpr in a query. 5 | sql_engine: Redshift 6 | --- 7 | -- Test Add Time Expression 8 | SELECT 9 | DATEADD(month, (1 * 3), '2020-01-01') AS add_time 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/BigQuery/test_component_rendering__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_component_rendering 2 | test_filename: test_sql_plan_render.py 3 | docstring: 4 | Checks that all components of SELECT query are rendered for the 0, 1, >1 component count cases. 5 | sql_engine: BigQuery 6 | --- 7 | -- test0 8 | SELECT 9 | SUM(1) AS bookings 10 | FROM demo.fct_bookings a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Postgres/test_component_rendering__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_component_rendering 2 | test_filename: test_sql_plan_render.py 3 | docstring: 4 | Checks that all components of SELECT query are rendered for the 0, 1, >1 component count cases. 5 | sql_engine: Postgres 6 | --- 7 | -- test0 8 | SELECT 9 | SUM(1) AS bookings 10 | FROM demo.fct_bookings a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Redshift/test_component_rendering__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_component_rendering 2 | test_filename: test_sql_plan_render.py 3 | docstring: 4 | Checks that all components of SELECT query are rendered for the 0, 1, >1 component count cases. 5 | sql_engine: Redshift 6 | --- 7 | -- test0 8 | SELECT 9 | SUM(1) AS bookings 10 | FROM demo.fct_bookings a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Snowflake/test_component_rendering__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_component_rendering 2 | test_filename: test_sql_plan_render.py 3 | docstring: 4 | Checks that all components of SELECT query are rendered for the 0, 1, >1 component count cases. 5 | sql_engine: Snowflake 6 | --- 7 | -- test0 8 | SELECT 9 | SUM(1) AS bookings 10 | FROM demo.fct_bookings a 11 | -------------------------------------------------------------------------------- /tests_metricflow/fixtures/source_table_snapshots/simple_multi_hop_join_manifest/entity_1_and_entity_2_measure_table.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | table_snapshot: 3 | table_name: entity_1_and_entity_2_measure_table 4 | column_definitions: 5 | - name: entity_1 6 | type: STRING 7 | - name: entity_2 8 | type: STRING 9 | - name: ds 10 | type: TIME 11 | rows: 12 | - ["E1_0", "E2_0", "2020-01-01"] 13 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Databricks/test_add_time_expr__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_add_time_expr 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the SqlAddTimeExpr in a query. 5 | sql_engine: Databricks 6 | --- 7 | -- Test Add Time Expression 8 | SELECT 9 | DATEADD(month, (1 * 3), '2020-01-01') AS add_time 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Snowflake/test_add_time_expr__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_add_time_expr 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the SqlAddTimeExpr in a query. 5 | sql_engine: Snowflake 6 | --- 7 | -- Test Add Time Expression 8 | SELECT 9 | DATEADD(month, (1 * 3), '2020-01-01') AS add_time 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_mf_engine.py/list/test_list_saved_queries__result0.txt: -------------------------------------------------------------------------------- 1 | test_name: test_list_saved_queries 2 | test_filename: test_mf_engine.py 3 | docstring: 4 | Test listing all saved_queries. 5 | --- 6 | [ 7 | 'dimensions_only', 8 | 'p0_booking', 9 | 'p0_booking_with_order_by_and_limit', 10 | 'saved_query_with_cumulative_metric', 11 | 'saved_query_with_metric_joins_and_filter', 12 | ] 13 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_query_output.py/str/DuckDB/test_scd_group_by_without_metric_time__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_scd_group_by_without_metric_time 2 | test_filename: test_query_output.py 3 | --- 4 | listing__capacity family_bookings 5 | ------------------- ----------------- 6 | 3 38 7 | 4 43 8 | 5 39 9 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Databricks/test_component_rendering__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_component_rendering 2 | test_filename: test_sql_plan_render.py 3 | docstring: 4 | Checks that all components of SELECT query are rendered for the 0, 1, >1 component count cases. 5 | sql_engine: Databricks 6 | --- 7 | -- test0 8 | SELECT 9 | SUM(1) AS bookings 10 | FROM demo.fct_bookings a 11 | -------------------------------------------------------------------------------- /tests_metricflow/table_snapshot/example_table_snapshot.yaml: -------------------------------------------------------------------------------- 1 | table_snapshot: 2 | table_name: example_table 3 | column_definitions: 4 | - name: user_id 5 | type: INT 6 | - name: name 7 | type: STRING 8 | - name: balance 9 | type: FLOAT 10 | - name: is_active 11 | type: BOOLEAN 12 | rows: 13 | - ["0", "user0", "0.0", "False"] 14 | - ["1", "user1", "0.1", "True"] 15 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/metricflow_semantic_interfaces/type_enums/conversion_calculation_type.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantic_interfaces.enum_extension import ExtendedEnum 4 | 5 | 6 | class ConversionCalculationType(ExtendedEnum): 7 | """Types of calculations for a conversion metric.""" 8 | 9 | CONVERSIONS = "conversions" 10 | CONVERSION_RATE = "conversion_rate" 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_conversion_metrics.py/str/DuckDB/test_conversion_metric_with_filter_not_in_group_by__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_conversion_metric_with_filter_not_in_group_by 2 | test_filename: test_conversion_metrics.py 3 | docstring: 4 | Test query against a conversion metric with a filter that doesn't exist in group by. 5 | --- 6 | visit_buy_conversions 7 | ----------------------- 8 | 3 9 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_conversion_metrics.py/str/Trino/test_conversion_metric_with_filter_not_in_group_by__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_conversion_metric_with_filter_not_in_group_by 2 | test_filename: test_conversion_metrics.py 3 | docstring: 4 | Test query against a conversion metric with a filter that doesn't exist in group by. 5 | --- 6 | visit_buy_conversions 7 | ----------------------- 8 | 3 9 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Trino/test_cast_to_timestamp__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_cast_to_timestamp 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the cast to timestamp expression in a query. 5 | sql_engine: Trino 6 | --- 7 | -- Test Cast to Timestamp Expression 8 | SELECT 9 | CAST('2020-01-01' AS TIMESTAMP) AS col0 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_conversion_metrics.py/str/BigQuery/test_conversion_metric_with_filter_not_in_group_by__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_conversion_metric_with_filter_not_in_group_by 2 | test_filename: test_conversion_metrics.py 3 | docstring: 4 | Test query against a conversion metric with a filter that doesn't exist in group by. 5 | --- 6 | visit_buy_conversions 7 | ----------------------- 8 | 3 9 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_conversion_metrics.py/str/Databricks/test_conversion_metric_with_filter_not_in_group_by__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_conversion_metric_with_filter_not_in_group_by 2 | test_filename: test_conversion_metrics.py 3 | docstring: 4 | Test query against a conversion metric with a filter that doesn't exist in group by. 5 | --- 6 | visit_buy_conversions 7 | ----------------------- 8 | 3 9 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_conversion_metrics.py/str/Postgres/test_conversion_metric_with_filter_not_in_group_by__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_conversion_metric_with_filter_not_in_group_by 2 | test_filename: test_conversion_metrics.py 3 | docstring: 4 | Test query against a conversion metric with a filter that doesn't exist in group by. 5 | --- 6 | visit_buy_conversions 7 | ----------------------- 8 | 3 9 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_conversion_metrics.py/str/Redshift/test_conversion_metric_with_filter_not_in_group_by__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_conversion_metric_with_filter_not_in_group_by 2 | test_filename: test_conversion_metrics.py 3 | docstring: 4 | Test query against a conversion metric with a filter that doesn't exist in group by. 5 | --- 6 | visit_buy_conversions 7 | ----------------------- 8 | 3 9 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_conversion_metrics.py/str/Snowflake/test_conversion_metric_with_filter_not_in_group_by__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_conversion_metric_with_filter_not_in_group_by 2 | test_filename: test_conversion_metrics.py 3 | docstring: 4 | Test query against a conversion metric with a filter that doesn't exist in group by. 5 | --- 6 | VISIT_BUY_CONVERSIONS 7 | ----------------------- 8 | 3 9 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/BigQuery/test_cast_to_timestamp__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_cast_to_timestamp 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the cast to timestamp expression in a query. 5 | sql_engine: BigQuery 6 | --- 7 | -- Test Cast to Timestamp Expression 8 | SELECT 9 | CAST('2020-01-01' AS DATETIME) AS col0 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/DuckDB/test_cast_to_timestamp__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_cast_to_timestamp 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the cast to timestamp expression in a query. 5 | sql_engine: DuckDB 6 | --- 7 | -- Test Cast to Timestamp Expression 8 | SELECT 9 | CAST('2020-01-01' AS TIMESTAMP) AS col0 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Postgres/test_cast_to_timestamp__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_cast_to_timestamp 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the cast to timestamp expression in a query. 5 | sql_engine: Postgres 6 | --- 7 | -- Test Cast to Timestamp Expression 8 | SELECT 9 | CAST('2020-01-01' AS TIMESTAMP) AS col0 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Redshift/test_cast_to_timestamp__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_cast_to_timestamp 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the cast to timestamp expression in a query. 5 | sql_engine: Redshift 6 | --- 7 | -- Test Cast to Timestamp Expression 8 | SELECT 9 | CAST('2020-01-01' AS TIMESTAMP) AS col0 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/DuckDB/test_join_to_time_spine_with_filter_smaller_than_group_by__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_filter_smaller_than_group_by 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | metric_time__day archived_users_join_to_time_spine 5 | ------------------- ----------------------------------- 6 | 2020-01-01T00:00:00 12 7 | -------------------------------------------------------------------------------- /dbt-metricflow/requirements-files/requirements-cli.txt: -------------------------------------------------------------------------------- 1 | # Internal dependencies 2 | dbt-core>=1.10.4, <1.11.0 3 | 4 | # dsi version should be fixed by MetricFlow/dbt-core, not set here 5 | dbt-semantic-interfaces 6 | 7 | # CLI-related 8 | Jinja2>=3.1.6, <3.7.0 9 | halo>=0.0.31, <0.1.0 10 | update-checker>=0.18.0, <0.19.0 11 | 12 | # Bug with mypy: https://github.com/pallets/click/issues/2558#issuecomment-1656546003 13 | click>=8.1.6 14 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/conftest.py: -------------------------------------------------------------------------------- 1 | # These imports are required to properly set up pytest fixtures. 2 | from __future__ import annotations 3 | 4 | from metricflow_semantics.test_helpers.id_helpers import setup_id_generators # noqa: F401 5 | 6 | from tests_metricflow_semantics.fixtures.manifest_fixtures import * # noqa: F401, F403 7 | from tests_metricflow_semantics.fixtures.setup_fixtures import * # noqa: F401, F403 8 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/snapshots/test_available_group_by_items.py/LinkableSpecSet/test_available_group_by_items__derived_metric_with_different_parent_time_grains__set0.txt: -------------------------------------------------------------------------------- 1 | test_name: test_available_group_by_items[derived_metric_with_different_parent_time_grains] 2 | test_filename: test_available_group_by_items.py 3 | --- 4 | ["TimeDimension('metric_time', 'year')", "TimeDimension('metric_time', date_part_name='year')"] 5 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/BigQuery/test_add_time_expr__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_add_time_expr 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the SqlAddTimeExpr in a query. 5 | sql_engine: BigQuery 6 | --- 7 | -- Test Add Time Expression 8 | SELECT 9 | DATE_ADD(CAST('2020-01-01' AS DATETIME), INTERVAL 1 quarter) AS add_time 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Databricks/test_cast_to_timestamp__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_cast_to_timestamp 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the cast to timestamp expression in a query. 5 | sql_engine: Databricks 6 | --- 7 | -- Test Cast to Timestamp Expression 8 | SELECT 9 | CAST('2020-01-01' AS TIMESTAMP) AS col0 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Postgres/test_add_time_expr__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_add_time_expr 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the SqlAddTimeExpr in a query. 5 | sql_engine: Postgres 6 | --- 7 | -- Test Add Time Expression 8 | SELECT 9 | '2020-01-01' + MAKE_INTERVAL(months => CAST ((1) AS INTEGER)) AS add_time 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Snowflake/test_cast_to_timestamp__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_cast_to_timestamp 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the cast to timestamp expression in a query. 5 | sql_engine: Snowflake 6 | --- 7 | -- Test Cast to Timestamp Expression 8 | SELECT 9 | CAST('2020-01-01' AS TIMESTAMP) AS col0 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/BigQuery/test_join_to_time_spine_with_filter_smaller_than_group_by__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_filter_smaller_than_group_by 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | metric_time__day archived_users_join_to_time_spine 5 | ------------------- ----------------------------------- 6 | 2020-01-01T00:00:00 12 7 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/BigQuery/test_join_to_timespine_metric_with_custom_granularity_filter__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_timespine_metric_with_custom_granularity_filter 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | metric_time__alien_day bookings_join_to_time_spine 5 | ------------------------ ----------------------------- 6 | 2020-01-02T00:00:00 31 7 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Databricks/test_join_to_time_spine_with_filter_smaller_than_group_by__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_filter_smaller_than_group_by 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | metric_time__day archived_users_join_to_time_spine 5 | ------------------- ----------------------------------- 6 | 2020-01-01T00:00:00 12 7 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/DuckDB/test_join_to_timespine_metric_with_custom_granularity_filter__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_timespine_metric_with_custom_granularity_filter 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | metric_time__alien_day bookings_join_to_time_spine 5 | ------------------------ ----------------------------- 6 | 2020-01-02T00:00:00 31 7 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Postgres/test_join_to_time_spine_with_filter_smaller_than_group_by__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_filter_smaller_than_group_by 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | metric_time__day archived_users_join_to_time_spine 5 | ------------------- ----------------------------------- 6 | 2020-01-01T00:00:00 12 7 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Postgres/test_join_to_timespine_metric_with_custom_granularity_filter__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_timespine_metric_with_custom_granularity_filter 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | metric_time__alien_day bookings_join_to_time_spine 5 | ------------------------ ----------------------------- 6 | 2020-01-02T00:00:00 31 7 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Redshift/test_join_to_time_spine_with_filter_smaller_than_group_by__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_filter_smaller_than_group_by 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | metric_time__day archived_users_join_to_time_spine 5 | ------------------- ----------------------------------- 6 | 2020-01-01T00:00:00 12 7 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Redshift/test_join_to_timespine_metric_with_custom_granularity_filter__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_timespine_metric_with_custom_granularity_filter 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | metric_time__alien_day bookings_join_to_time_spine 5 | ------------------------ ----------------------------- 6 | 2020-01-02T00:00:00 31 7 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Snowflake/test_join_to_time_spine_with_filter_smaller_than_group_by__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_filter_smaller_than_group_by 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | METRIC_TIME__DAY ARCHIVED_USERS_JOIN_TO_TIME_SPINE 5 | ------------------- ----------------------------------- 6 | 2020-01-01T00:00:00 12 7 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Databricks/test_join_to_timespine_metric_with_custom_granularity_filter__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_timespine_metric_with_custom_granularity_filter 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | metric_time__alien_day bookings_join_to_time_spine 5 | ------------------------ ----------------------------- 6 | 2020-01-02T00:00:00 31 7 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Snowflake/test_join_to_timespine_metric_with_custom_granularity_filter__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_timespine_metric_with_custom_granularity_filter 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | METRIC_TIME__ALIEN_DAY BOOKINGS_JOIN_TO_TIME_SPINE 5 | ------------------------ ----------------------------- 6 | 2020-01-02T00:00:00 31 7 | -------------------------------------------------------------------------------- /dbt-metricflow/tests_dbt_metricflow/snapshots/test_output_format.py/str/test_decimals_option_negative__result.txt: -------------------------------------------------------------------------------- 1 | test_name: test_decimals_option_negative 2 | test_filename: test_output_format.py 3 | docstring: 4 | Tests the output of `mf query --decimals -1 ...`. 5 | expectation_description: 6 | An error should be displayed due to the invalid argument value. 7 | --- 8 | ❌ The `decimals` option was set to -1, but it should be a non-negative integer. 9 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_column_pruner.py/SqlPlan/test_prune_distinct_select__after_pruning.sql: -------------------------------------------------------------------------------- 1 | test_name: test_prune_distinct_select 2 | test_filename: test_column_pruner.py 3 | docstring: 4 | Test that distinct select node shouldn't be pruned. 5 | --- 6 | -- test0 7 | SELECT 8 | a.booking_value 9 | FROM ( 10 | -- test1 11 | SELECT DISTINCT 12 | a.booking_value 13 | , a.bookings 14 | FROM demo.fct_bookings a 15 | ) b 16 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_column_pruner.py/SqlPlan/test_prune_distinct_select__before_pruning.sql: -------------------------------------------------------------------------------- 1 | test_name: test_prune_distinct_select 2 | test_filename: test_column_pruner.py 3 | docstring: 4 | Test that distinct select node shouldn't be pruned. 5 | --- 6 | -- test0 7 | SELECT 8 | a.booking_value 9 | FROM ( 10 | -- test1 11 | SELECT DISTINCT 12 | a.booking_value 13 | , a.bookings 14 | FROM demo.fct_bookings a 15 | ) b 16 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/metricflow_semantic_interfaces/type_enums/metric_type.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantic_interfaces.enum_extension import ExtendedEnum 4 | 5 | 6 | class MetricType(ExtendedEnum): 7 | """Currently supported metric types.""" 8 | 9 | SIMPLE = "simple" 10 | RATIO = "ratio" 11 | CUMULATIVE = "cumulative" 12 | DERIVED = "derived" 13 | CONVERSION = "conversion" 14 | -------------------------------------------------------------------------------- /tests_metricflow/fixtures/source_table_snapshots/simple_multi_hop_join_manifest/all_entity_measure_table.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | table_snapshot: 3 | table_name: all_entity_measure_table 4 | column_definitions: 5 | - name: entity_0 6 | type: STRING 7 | - name: entity_1 8 | type: STRING 9 | - name: entity_2 10 | type: STRING 11 | - name: ds 12 | type: TIME 13 | rows: 14 | - ["E0_0", "E1_1", "E1_2", "2020-01-01"] 15 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/semantic_graph/sg_exceptions.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import logging 4 | 5 | from metricflow_semantics.errors.error_classes import MetricFlowInternalError 6 | 7 | logger = logging.getLogger(__name__) 8 | 9 | 10 | class SemanticGraphTraversalError(MetricFlowInternalError): 11 | """Raised when an unexpected condition is encountered during semantic-graph traversal.""" 12 | 13 | pass 14 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/snapshots/test_messages.py/str/test_empty_query__result.txt: -------------------------------------------------------------------------------- 1 | test_name: test_empty_query 2 | test_filename: test_messages.py 3 | docstring: 4 | Test the error message for an empty query. 5 | --- 6 | Got error(s) during query resolution. 7 | 8 | Error #1: 9 | Message: 10 | 11 | There are no metrics or group by items requested in the query. 12 | 13 | Issue Location: 14 | 15 | [Resolve Query()] 16 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_query_output.py/str/DuckDB/test_semi_additive_measure_with_where_filter__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_semi_additive_measure_with_where_filter 2 | test_filename: test_query_output.py 3 | --- 4 | user current_account_balance_by_user 5 | -------- --------------------------------- 6 | u0004114 1213 7 | u0005414 5582 8 | u0005432 234 9 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/extended_date_manifest/metrics/bookings_last_month.yaml: -------------------------------------------------------------------------------- 1 | metric: 2 | name: bookings_last_month 3 | description: bookings the prior month, based on dimension with month granularity 4 | type: derived 5 | type_params: 6 | expr: bookings_last_month 7 | metrics: 8 | - name: bookings_monthly 9 | offset_window: 1 month 10 | alias: bookings_last_month 11 | -------------------------------------------------------------------------------- /metricflow-semantics/requirements-files/requirements.txt: -------------------------------------------------------------------------------- 1 | # Always support a range of production DSI versions capped at the next breaking version in metricflow-semantics. 2 | # This allows us to sync new, non-breaking changes to dbt-core without getting a version mismatch in dbt-mantle, 3 | # which depends on a specific commit of DSI. 4 | dbt-semantic-interfaces>=0.9.4.dev0, <0.11.0 5 | graphviz>=0.18.2, <0.21 6 | python-dateutil>=2.9.0, <2.10.0 7 | rapidfuzz>=3.0, <4.0 8 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/DuckDB/test_join_to_time_spine_with_filter_not_in_group_by__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_filter_not_in_group_by 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | metric_time__day bookings_join_to_time_spine_with_tiered_filters 5 | ------------------- ------------------------------------------------- 6 | 2020-01-02T00:00:00 9 7 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/extended_date_manifest/metrics/monthly_bookings_to_daily_bookings_ratio.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | metric: 3 | name: monthly_bookings_to_daily_bookings 4 | description: Ratio of daily bookings that are included in the monthly bookings total as a derived metric. 5 | type: ratio 6 | type_params: 7 | numerator: 8 | name: bookings 9 | denominator: 10 | name: bookings_monthly 11 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/multi_hop_join_manifest/third_hop_table.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | semantic_model: 3 | name: third_hop_table 4 | description: third_hop_table 5 | 6 | node_relation: 7 | schema_name: $source_schema 8 | alias: third_hop_table 9 | 10 | dimensions: 11 | - name: value 12 | type: categorical 13 | 14 | entities: 15 | - name: customer_third_hop_id 16 | type: primary 17 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_filter_not_in_group_by 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | metric_time__day bookings_join_to_time_spine_with_tiered_filters 5 | ------------------- ------------------------------------------------- 6 | 2020-01-02T00:00:00 9 7 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Databricks/test_join_to_time_spine_with_filter_not_in_group_by__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_filter_not_in_group_by 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | metric_time__day bookings_join_to_time_spine_with_tiered_filters 5 | ------------------- ------------------------------------------------- 6 | 2020-01-02T00:00:00 9 7 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Postgres/test_join_to_time_spine_with_filter_not_in_group_by__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_filter_not_in_group_by 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | metric_time__day bookings_join_to_time_spine_with_tiered_filters 5 | ------------------- ------------------------------------------------- 6 | 2020-01-02T00:00:00 9 7 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Redshift/test_join_to_time_spine_with_filter_not_in_group_by__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_filter_not_in_group_by 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | metric_time__day bookings_join_to_time_spine_with_tiered_filters 5 | ------------------- ------------------------------------------------- 6 | 2020-01-02T00:00:00 9 7 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_filter_not_in_group_by 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | METRIC_TIME__DAY BOOKINGS_JOIN_TO_TIME_SPINE_WITH_TIERED_FILTERS 5 | ------------------- ------------------------------------------------- 6 | 2020-01-02T00:00:00 9 7 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/metricflow_semantic_interfaces/type_enums/semantic_manifest_node_type.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantic_interfaces.enum_extension import ExtendedEnum 4 | 5 | 6 | class SemanticManifestNodeType(ExtendedEnum): 7 | """Currently supported node types.""" 8 | 9 | METRIC = "metric" 10 | SAVED_QUERY = "saved_query" 11 | SEMANTIC_MODEL = "semantic_model" 12 | TIME_SPINE = "time_spine" 13 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_mf_engine.py/list/test_entities_for_metrics__result0.txt: -------------------------------------------------------------------------------- 1 | test_name: test_entities_for_metrics 2 | test_filename: test_mf_engine.py 3 | docstring: 4 | Test listing entities with metric filter. 5 | --- 6 | [ 7 | ('companies', 'company'), 8 | ('bookings_source', 'guest'), 9 | ('bookings_source', 'host'), 10 | ('bookings_source', 'listing'), 11 | ('lux_listing_mapping', 'lux_listing'), 12 | ('listings_latest', 'user'), 13 | ] 14 | -------------------------------------------------------------------------------- /metricflow/plan_conversion/convert_to_sql_plan.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from dataclasses import dataclass 4 | 5 | from metricflow_semantics.instances import InstanceSet 6 | 7 | from metricflow.sql.sql_plan import SqlPlan 8 | 9 | 10 | @dataclass(frozen=True) 11 | class ConvertToSqlPlanResult: 12 | """Result object for returning the results of converting to a `SqlQueryPlan`.""" 13 | 14 | instance_set: InstanceSet 15 | sql_plan: SqlPlan 16 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Redshift/test_generate_uuid__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_generate_uuid 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the generate uuid expression in a query. 5 | sql_engine: Redshift 6 | --- 7 | -- Test Generate UUID Expression 8 | SELECT 9 | CONCAT(CAST(RANDOM()*100000000 AS INT)::VARCHAR,CAST(RANDOM()*100000000 AS INT)::VARCHAR) AS uuid 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /dbt-metricflow/tests_dbt_metricflow/snapshots/test_isolated_command_runner.py/str/test_environment_variables__result.txt: -------------------------------------------------------------------------------- 1 | test_name: test_environment_variables 2 | test_filename: test_isolated_command_runner.py 3 | docstring: 4 | Tests running an MF CLI command that configures the profile / project location using environment variables. 5 | expectation_description: 6 | A table showing the `transactions` metric. 7 | --- 8 | transactions 9 | -------------- 10 | 50 11 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/metricflow_semantic_interfaces/type_enums/entity_type.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantic_interfaces.enum_extension import ExtendedEnum 4 | 5 | 6 | class EntityType(ExtendedEnum): 7 | """Defines uniqueness and the extent to which an entity represents the common entity for a semantic model.""" 8 | 9 | FOREIGN = "foreign" 10 | NATURAL = "natural" 11 | PRIMARY = "primary" 12 | UNIQUE = "unique" 13 | -------------------------------------------------------------------------------- /metricflow/sql_request/sql_request_attributes.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import logging 4 | from dataclasses import dataclass 5 | 6 | logger = logging.getLogger(__name__) 7 | 8 | 9 | @dataclass(frozen=True) 10 | class SqlRequestId: 11 | """Identifies a request (i.e. a call to SqlClient.query() or SqlClient.execute()) to the SQL engine.""" 12 | 13 | id_str: str 14 | 15 | def __repr__(self) -> str: # noqa: D105 16 | return self.id_str 17 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/DuckDB/test_discrete_percentile_expr__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_discrete_percentile_expr 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the discrete percentile expression in a query. 5 | sql_engine: DuckDB 6 | --- 7 | -- Test Discrete Percentile Expression 8 | SELECT 9 | PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY (a.col0)) AS col0_percentile 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/DuckDB/test_component_rendering__plan1.sql: -------------------------------------------------------------------------------- 1 | test_name: test_component_rendering 2 | test_filename: test_sql_plan_render.py 3 | docstring: 4 | Checks that all components of SELECT query are rendered for the 0, 1, >1 component count cases. 5 | sql_engine: DuckDB 6 | --- 7 | -- test1 8 | SELECT 9 | SUM(1) AS bookings 10 | , b.country AS user__country 11 | , c.country AS listing__country 12 | FROM demo.fct_bookings a 13 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Trino/test_component_rendering__plan1.sql: -------------------------------------------------------------------------------- 1 | test_name: test_component_rendering 2 | test_filename: test_sql_plan_render.py 3 | docstring: 4 | Checks that all components of SELECT query are rendered for the 0, 1, >1 component count cases. 5 | sql_engine: Trino 6 | --- 7 | -- test1 8 | SELECT 9 | SUM(1) AS bookings 10 | , b.country AS user__country 11 | , c.country AS listing__country 12 | FROM demo.fct_bookings a 13 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/join_types_manifest/listings_source.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | semantic_model: 3 | name: listings_source 4 | description: listings_source 5 | 6 | node_relation: 7 | schema_name: $source_schema 8 | alias: dim_listings_for_joins 9 | 10 | dimensions: 11 | - name: country 12 | type: categorical 13 | 14 | entities: 15 | - name: listing 16 | type: primary 17 | expr: listing_id 18 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/snapshots/test_dot.py/str/test_dot_text__result.txt: -------------------------------------------------------------------------------- 1 | test_name: test_dot_text 2 | test_filename: test_dot.py 3 | docstring: 4 | Check formatting of the graph using DOT notation. 5 | --- 6 | digraph { 7 | graph [name=FlowGraph] 8 | sink 9 | source 10 | subgraph cluster_intermediate_nodes { 11 | label=intermediate_nodes 12 | a 13 | b 14 | } 15 | source -> a 16 | source -> b 17 | a -> b 18 | a -> sink 19 | b -> sink 20 | } 21 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/DuckDB/test_continuous_percentile_expr__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_continuous_percentile_expr 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the continuous percentile expression in a query. 5 | sql_engine: DuckDB 6 | --- 7 | -- Test Continuous Percentile Expression 8 | SELECT 9 | PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY (a.col0)) AS col0_percentile 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Postgres/test_discrete_percentile_expr__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_discrete_percentile_expr 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the discrete percentile expression in a query. 5 | sql_engine: Postgres 6 | --- 7 | -- Test Discrete Percentile Expression 8 | SELECT 9 | PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY (a.col0)) AS col0_percentile 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Snowflake/test_discrete_percentile_expr__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_discrete_percentile_expr 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the discrete percentile expression in a query. 5 | sql_engine: Snowflake 6 | --- 7 | -- Test Discrete Percentile Expression 8 | SELECT 9 | PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY (a.col0)) AS col0_percentile 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/BigQuery/test_component_rendering__plan1.sql: -------------------------------------------------------------------------------- 1 | test_name: test_component_rendering 2 | test_filename: test_sql_plan_render.py 3 | docstring: 4 | Checks that all components of SELECT query are rendered for the 0, 1, >1 component count cases. 5 | sql_engine: BigQuery 6 | --- 7 | -- test1 8 | SELECT 9 | SUM(1) AS bookings 10 | , b.country AS user__country 11 | , c.country AS listing__country 12 | FROM demo.fct_bookings a 13 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Postgres/test_component_rendering__plan1.sql: -------------------------------------------------------------------------------- 1 | test_name: test_component_rendering 2 | test_filename: test_sql_plan_render.py 3 | docstring: 4 | Checks that all components of SELECT query are rendered for the 0, 1, >1 component count cases. 5 | sql_engine: Postgres 6 | --- 7 | -- test1 8 | SELECT 9 | SUM(1) AS bookings 10 | , b.country AS user__country 11 | , c.country AS listing__country 12 | FROM demo.fct_bookings a 13 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Redshift/test_component_rendering__plan1.sql: -------------------------------------------------------------------------------- 1 | test_name: test_component_rendering 2 | test_filename: test_sql_plan_render.py 3 | docstring: 4 | Checks that all components of SELECT query are rendered for the 0, 1, >1 component count cases. 5 | sql_engine: Redshift 6 | --- 7 | -- test1 8 | SELECT 9 | SUM(1) AS bookings 10 | , b.country AS user__country 11 | , c.country AS listing__country 12 | FROM demo.fct_bookings a 13 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Snowflake/test_component_rendering__plan1.sql: -------------------------------------------------------------------------------- 1 | test_name: test_component_rendering 2 | test_filename: test_sql_plan_render.py 3 | docstring: 4 | Checks that all components of SELECT query are rendered for the 0, 1, >1 component count cases. 5 | sql_engine: Snowflake 6 | --- 7 | -- test1 8 | SELECT 9 | SUM(1) AS bookings 10 | , b.country AS user__country 11 | , c.country AS listing__country 12 | FROM demo.fct_bookings a 13 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_conversion_metrics.py/str/DuckDB/test_conversion_metric_with_time_constraint__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_conversion_metric_with_time_constraint 2 | test_filename: test_conversion_metrics.py 3 | docstring: 4 | Test query against a conversion metric with a time constraint and categorical filter. 5 | --- 6 | visit__referrer_id visit_buy_conversion_rate 7 | -------------------- --------------------------- 8 | fb_ad_1 1.5 9 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_conversion_metrics.py/str/Trino/test_conversion_metric_with_time_constraint__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_conversion_metric_with_time_constraint 2 | test_filename: test_conversion_metrics.py 3 | docstring: 4 | Test query against a conversion metric with a time constraint and categorical filter. 5 | --- 6 | visit__referrer_id visit_buy_conversion_rate 7 | -------------------- --------------------------- 8 | fb_ad_1 1.5 9 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Postgres/test_continuous_percentile_expr__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_continuous_percentile_expr 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the continuous percentile expression in a query. 5 | sql_engine: Postgres 6 | --- 7 | -- Test Continuous Percentile Expression 8 | SELECT 9 | PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY (a.col0)) AS col0_percentile 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Redshift/test_continuous_percentile_expr__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_continuous_percentile_expr 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the continuous percentile expression in a query. 5 | sql_engine: Redshift 6 | --- 7 | -- Test Continuous Percentile Expression 8 | SELECT 9 | PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY (a.col0)) AS col0_percentile 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/DuckDB/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | booking__ds__day bookings_join_to_time_spine_with_tiered_filters 5 | ------------------- ------------------------------------------------- 6 | 2020-01-02T00:00:00 9 7 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_mf_engine.py/list/test_list_dimensions_for_metrics_for_multiple_metrics__result0.txt: -------------------------------------------------------------------------------- 1 | test_name: test_list_dimensions_for_metrics_for_multiple_metrics 2 | test_filename: test_mf_engine.py 3 | docstring: 4 | Test getting common dimensions for multiple metrics. 5 | --- 6 | [ 7 | 'listing__capacity_latest', 8 | 'listing__country_latest', 9 | 'listing__created_at', 10 | 'listing__ds', 11 | 'listing__is_lux_latest', 12 | 'metric_time__day', 13 | ] 14 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Databricks/test_component_rendering__plan1.sql: -------------------------------------------------------------------------------- 1 | test_name: test_component_rendering 2 | test_filename: test_sql_plan_render.py 3 | docstring: 4 | Checks that all components of SELECT query are rendered for the 0, 1, >1 component count cases. 5 | sql_engine: Databricks 6 | --- 7 | -- test1 8 | SELECT 9 | SUM(1) AS bookings 10 | , b.country AS user__country 11 | , c.country AS listing__country 12 | FROM demo.fct_bookings a 13 | -------------------------------------------------------------------------------- /dbt-metricflow/dbt_metricflow/cli/cli_errors.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | import textwrap 4 | 5 | 6 | class LoadSemanticManifestException(Exception): 7 | """Errors related to loading a semantic manifest.""" 8 | 9 | def __init__(self, msg: str = "") -> None: # noqa: D107 10 | error_msg = "Unable to load the semantic manifest." 11 | if msg: 12 | error_msg += f"\n{textwrap.indent(msg, prefix=' ')}" 13 | super().__init__(error_msg) 14 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_conversion_metrics.py/str/BigQuery/test_conversion_metric_with_time_constraint__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_conversion_metric_with_time_constraint 2 | test_filename: test_conversion_metrics.py 3 | docstring: 4 | Test query against a conversion metric with a time constraint and categorical filter. 5 | --- 6 | visit__referrer_id visit_buy_conversion_rate 7 | -------------------- --------------------------- 8 | fb_ad_1 1.5 9 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_conversion_metrics.py/str/Databricks/test_conversion_metric_with_time_constraint__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_conversion_metric_with_time_constraint 2 | test_filename: test_conversion_metrics.py 3 | docstring: 4 | Test query against a conversion metric with a time constraint and categorical filter. 5 | --- 6 | visit__referrer_id visit_buy_conversion_rate 7 | -------------------- --------------------------- 8 | fb_ad_1 1.5 9 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_conversion_metrics.py/str/Postgres/test_conversion_metric_with_time_constraint__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_conversion_metric_with_time_constraint 2 | test_filename: test_conversion_metrics.py 3 | docstring: 4 | Test query against a conversion metric with a time constraint and categorical filter. 5 | --- 6 | visit__referrer_id visit_buy_conversion_rate 7 | -------------------- --------------------------- 8 | fb_ad_1 1.5 9 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_conversion_metrics.py/str/Redshift/test_conversion_metric_with_time_constraint__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_conversion_metric_with_time_constraint 2 | test_filename: test_conversion_metrics.py 3 | docstring: 4 | Test query against a conversion metric with a time constraint and categorical filter. 5 | --- 6 | visit__referrer_id visit_buy_conversion_rate 7 | -------------------- --------------------------- 8 | fb_ad_1 1.5 9 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_conversion_metrics.py/str/Snowflake/test_conversion_metric_with_time_constraint__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_conversion_metric_with_time_constraint 2 | test_filename: test_conversion_metrics.py 3 | docstring: 4 | Test query against a conversion metric with a time constraint and categorical filter. 5 | --- 6 | VISIT__REFERRER_ID VISIT_BUY_CONVERSION_RATE 7 | -------------------- --------------------------- 8 | fb_ad_1 1.5 9 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Databricks/test_continuous_percentile_expr__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_continuous_percentile_expr 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the continuous percentile expression in a query. 5 | sql_engine: Databricks 6 | --- 7 | -- Test Continuous Percentile Expression 8 | SELECT 9 | PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY (a.col0)) AS col0_percentile 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Snowflake/test_continuous_percentile_expr__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_continuous_percentile_expr 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the continuous percentile expression in a query. 5 | sql_engine: Snowflake 6 | --- 7 | -- Test Continuous Percentile Expression 8 | SELECT 9 | PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY (a.col0)) AS col0_percentile 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | booking__ds__day bookings_join_to_time_spine_with_tiered_filters 5 | ------------------- ------------------------------------------------- 6 | 2020-01-02T00:00:00 9 7 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Databricks/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | booking__ds__day bookings_join_to_time_spine_with_tiered_filters 5 | ------------------- ------------------------------------------------- 6 | 2020-01-02T00:00:00 9 7 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Postgres/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | booking__ds__day bookings_join_to_time_spine_with_tiered_filters 5 | ------------------- ------------------------------------------------- 6 | 2020-01-02T00:00:00 9 7 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Redshift/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | booking__ds__day bookings_join_to_time_spine_with_tiered_filters 5 | ------------------- ------------------------------------------------- 6 | 2020-01-02T00:00:00 9 7 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | BOOKING__DS__DAY BOOKINGS_JOIN_TO_TIME_SPINE_WITH_TIERED_FILTERS 5 | ------------------- ------------------------------------------------- 6 | 2020-01-02T00:00:00 9 7 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/multi_hop_join_manifest/bridge_table.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | semantic_model: 3 | name: bridge_table 4 | description: bridge_table 5 | 6 | node_relation: 7 | schema_name: $source_schema 8 | alias: bridge_table 9 | 10 | dimensions: 11 | - name: extra_dim 12 | type: categorical 13 | 14 | entities: 15 | - name: account_id 16 | type: primary 17 | - name: customer_id 18 | type: foreign 19 | -------------------------------------------------------------------------------- /pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | # Don't scan for tests in the snapshot directory as they don't contain tests. 3 | # Speeds up initialization a little bit and also prevent parsing errors. 4 | norecursedirs = 5 | tests_metricflow/snapshots 6 | metricflow-semantics/tests_metricflow_semantics/snapshots 7 | git_ignored 8 | 9 | log_format = %(asctime)s %(levelname)-5s %(filename)s:%(lineno)d %(message)s 10 | log_date_format = %Y-%m-%d %H:%M:%S 11 | python_functions = test_* populate_source_schema 12 | -------------------------------------------------------------------------------- /.changes/v0.208.1.md: -------------------------------------------------------------------------------- 1 | ## MetricFlow v0.208.1 - September 18, 2025 2 | 3 | ### Fixes 4 | 5 | - Apply offset join after aggregation when queried grain is available post-aggregation. This ensures results match user expectations. 6 | - Pin to the latest non-dev release of dbt-semantic-interfaces. ([#1854](https://github.com/dbt-labs/metricflow/issues/1854)) 7 | 8 | ### Contributors 9 | - [@courtneyholcomb](https://github.com/courtneyholcomb) ([#1854](https://github.com/dbt-labs/metricflow/issues/1854)) 10 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/simple_multi_hop_join_manifest/entity_1_to_entity_0_mapping_source.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | semantic_model: 3 | name: entity_1_to_entity_0_mapping_source 4 | description: Maps "entity_1" to "entity_0" 5 | 6 | node_relation: 7 | schema_name: $source_schema 8 | alias: entity_1_to_entity_0_mapping_table 9 | 10 | entities: 11 | - name: entity_1 12 | type: primary 13 | - name: entity_0 14 | type: foreign 15 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/simple_multi_hop_join_manifest/entity_2_to_entity_0_mapping_source.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | semantic_model: 3 | name: entity_2_to_entity_0_mapping_source 4 | description: Maps "entity_2" to "entity_0" 5 | 6 | node_relation: 7 | schema_name: $source_schema 8 | alias: entity_2_to_entity_0_mapping_table 9 | 10 | entities: 11 | - name: entity_2 12 | type: primary 13 | - name: entity_0 14 | type: foreign 15 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/simple_multi_hop_join_manifest/entity_0_dimension_source.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | semantic_model: 3 | name: entity_0_dimension_source 4 | description: Contains dimensions for "entity_0" 5 | 6 | node_relation: 7 | schema_name: $source_schema 8 | alias: entity_0_dimension_table 9 | 10 | dimensions: 11 | - name: country 12 | type: categorical 13 | 14 | entities: 15 | - name: entity_0 16 | type: primary 17 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/simple_multi_hop_join_manifest/entity_1_dimension_source.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | semantic_model: 3 | name: entity_1_dimension_source 4 | description: Contains dimensions for "entity_1" 5 | 6 | node_relation: 7 | schema_name: $source_schema 8 | alias: entity_1_dimension_table 9 | 10 | dimensions: 11 | - name: country 12 | type: categorical 13 | 14 | entities: 15 | - name: entity_1 16 | type: primary 17 | -------------------------------------------------------------------------------- /metricflow/sql/optimizer/sql_query_plan_optimizer.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from abc import ABC, abstractmethod 4 | 5 | from metricflow.sql.sql_plan import SqlPlanNode 6 | 7 | 8 | class SqlPlanOptimizer(ABC): 9 | """Optimize the SQL query plan in some way. 10 | 11 | e.g. a column pruner that removes unnecessary select columns in sub-queries. 12 | """ 13 | 14 | @abstractmethod 15 | def optimize(self, node: SqlPlanNode) -> SqlPlanNode: # noqa :D 16 | pass 17 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/Trino/test_build_metric_tasks__query0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_build_metric_tasks 2 | test_filename: test_data_warehouse_tasks.py 3 | sql_engine: Trino 4 | --- 5 | SELECT 6 | metric_time__day 7 | , SUM(__count_dogs) AS count_dogs 8 | FROM ( 9 | SELECT 10 | DATE_TRUNC('day', ds) AS metric_time__day 11 | , 1 AS __count_dogs 12 | FROM ***************************.fct_animals animals_src_10000 13 | ) subq_3 14 | GROUP BY 15 | metric_time__day 16 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Databricks/test_approximate_discrete_percentile_expr__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_approximate_discrete_percentile_expr 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the approximate discrete percentile expression in a query. 5 | sql_engine: Databricks 6 | --- 7 | -- Test Approximate Discrete Percentile Expression 8 | SELECT 9 | APPROX_PERCENTILE(a.col0, 0.5) AS col0_percentile 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/DuckDB/test_approximate_continuous_percentile_expr__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_approximate_continuous_percentile_expr 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the approximate continuous percentile expression in a query. 5 | sql_engine: DuckDB 6 | --- 7 | -- Test Approximate Continuous Percentile Expression 8 | SELECT 9 | approx_quantile(a.col0, 0.5) AS col0_percentile 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Trino/test_approximate_continuous_percentile_expr__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_approximate_continuous_percentile_expr 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the approximate continuous percentile expression in a query. 5 | sql_engine: Trino 6 | --- 7 | -- Test Approximate Continuous Percentile Expression 8 | SELECT 9 | approx_percentile(a.col0, 0.5) AS col0_percentile 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/DuckDB/test_build_metric_tasks__query0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_build_metric_tasks 2 | test_filename: test_data_warehouse_tasks.py 3 | sql_engine: DuckDB 4 | --- 5 | SELECT 6 | metric_time__day 7 | , SUM(__count_dogs) AS count_dogs 8 | FROM ( 9 | SELECT 10 | DATE_TRUNC('day', ds) AS metric_time__day 11 | , 1 AS __count_dogs 12 | FROM ***************************.fct_animals animals_src_10000 13 | ) subq_3 14 | GROUP BY 15 | metric_time__day 16 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/tests/fixtures/semantic_manifest_yamls/simple_semantic_manifest/semantic_models/lux_listing_mapping.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | semantic_model: 3 | name: lux_listing_mapping 4 | description: lux_listing_mapping 5 | 6 | node_relation: 7 | schema_name: $source_schema 8 | alias: dim_lux_listing_id_mapping 9 | 10 | entities: 11 | - name: listing 12 | type: primary 13 | expr: listing_id 14 | - name: lux_listing 15 | type: foreign 16 | expr: lux_listing_id 17 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/simple_manifest/semantic_models/lux_listing_mapping.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | semantic_model: 3 | name: lux_listing_mapping 4 | description: lux_listing_mapping 5 | 6 | node_relation: 7 | schema_name: $source_schema 8 | alias: dim_lux_listing_id_mapping 9 | 10 | entities: 11 | - name: listing 12 | type: primary 13 | expr: listing_id 14 | - name: lux_listing 15 | type: foreign 16 | expr: lux_listing_id 17 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/time/time_source.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from abc import ABC, abstractmethod 4 | from datetime import datetime 5 | 6 | 7 | class TimeSource(ABC): 8 | """Provides time to classes that need a sense of time. 9 | 10 | A static time source can be used for testing, while a time source that uses the current time is used for production. 11 | """ 12 | 13 | @abstractmethod 14 | def get_time(self) -> datetime: # noqa: D102 15 | pass 16 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/snapshots/test_path_finder.py/FindAncestorsResult/test_find_ancestors__result.txt: -------------------------------------------------------------------------------- 1 | test_name: test_find_ancestors 2 | test_filename: test_path_finder.py 3 | --- 4 | FindAncestorsResult( 5 | reachable_nodes={SourceNode('source'), SinkNode('sink'), IntermediateNode('a'), IntermediateNode('b')}, 6 | reachable_source_nodes={SourceNode('source')}, 7 | source_node_to_reachable_target_nodes={SourceNode('source'): {SinkNode('sink')}}, 8 | finish_iteration_index=4, 9 | ) 10 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/BigQuery/test_build_metric_tasks__query0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_build_metric_tasks 2 | test_filename: test_data_warehouse_tasks.py 3 | sql_engine: BigQuery 4 | --- 5 | SELECT 6 | metric_time__day 7 | , SUM(__count_dogs) AS count_dogs 8 | FROM ( 9 | SELECT 10 | DATETIME_TRUNC(ds, day) AS metric_time__day 11 | , 1 AS __count_dogs 12 | FROM ***************************.fct_animals animals_src_10000 13 | ) subq_3 14 | GROUP BY 15 | metric_time__day 16 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/Databricks/test_build_metric_tasks__query0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_build_metric_tasks 2 | test_filename: test_data_warehouse_tasks.py 3 | sql_engine: Databricks 4 | --- 5 | SELECT 6 | metric_time__day 7 | , SUM(__count_dogs) AS count_dogs 8 | FROM ( 9 | SELECT 10 | DATE_TRUNC('day', ds) AS metric_time__day 11 | , 1 AS __count_dogs 12 | FROM ***************************.fct_animals animals_src_10000 13 | ) subq_3 14 | GROUP BY 15 | metric_time__day 16 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/Postgres/test_build_metric_tasks__query0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_build_metric_tasks 2 | test_filename: test_data_warehouse_tasks.py 3 | sql_engine: Postgres 4 | --- 5 | SELECT 6 | metric_time__day 7 | , SUM(__count_dogs) AS count_dogs 8 | FROM ( 9 | SELECT 10 | DATE_TRUNC('day', ds) AS metric_time__day 11 | , 1 AS __count_dogs 12 | FROM ***************************.fct_animals animals_src_10000 13 | ) subq_3 14 | GROUP BY 15 | metric_time__day 16 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/Redshift/test_build_metric_tasks__query0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_build_metric_tasks 2 | test_filename: test_data_warehouse_tasks.py 3 | sql_engine: Redshift 4 | --- 5 | SELECT 6 | metric_time__day 7 | , SUM(__count_dogs) AS count_dogs 8 | FROM ( 9 | SELECT 10 | DATE_TRUNC('day', ds) AS metric_time__day 11 | , 1 AS __count_dogs 12 | FROM ***************************.fct_animals animals_src_10000 13 | ) subq_3 14 | GROUP BY 15 | metric_time__day 16 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_data_warehouse_tasks.py/str/Snowflake/test_build_metric_tasks__query0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_build_metric_tasks 2 | test_filename: test_data_warehouse_tasks.py 3 | sql_engine: Snowflake 4 | --- 5 | SELECT 6 | metric_time__day 7 | , SUM(__count_dogs) AS count_dogs 8 | FROM ( 9 | SELECT 10 | DATE_TRUNC('day', ds) AS metric_time__day 11 | , 1 AS __count_dogs 12 | FROM ***************************.fct_animals animals_src_10000 13 | ) subq_3 14 | GROUP BY 15 | metric_time__day 16 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Snowflake/test_approximate_continuous_percentile_expr__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_approximate_continuous_percentile_expr 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the approximate continuous percentile expression in a query. 5 | sql_engine: Snowflake 6 | --- 7 | -- Test Approximate Continuous Percentile Expression 8 | SELECT 9 | APPROX_PERCENTILE(a.col0, 0.5) AS col0_percentile 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/multi_hop_join_manifest/customer_table.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | semantic_model: 3 | name: customer_table 4 | description: customer_table 5 | 6 | node_relation: 7 | schema_name: $source_schema 8 | alias: customer_table 9 | 10 | dimensions: 11 | - name: customer_name 12 | type: categorical 13 | - name: customer_atomic_weight 14 | type: categorical 15 | 16 | entities: 17 | - name: customer_id 18 | type: primary 19 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/snapshots/test_path_finder.py/FindDescendantsResult/test_find_descendants__result.txt: -------------------------------------------------------------------------------- 1 | test_name: test_find_descendants 2 | test_filename: test_path_finder.py 3 | --- 4 | FindDescendantsResult( 5 | reachable_nodes={IntermediateNode('a'), IntermediateNode('b'), SinkNode('sink')}, 6 | reachable_target_nodes={SinkNode('sink')}, 7 | finish_iteration_index=3, 8 | target_node_to_reachable_source_nodes={SinkNode('sink'): {IntermediateNode('a'), IntermediateNode('b')}}, 9 | ) 10 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/toolkit/test_ordered_enum.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantics.toolkit.orderd_enum import OrderedEnum 4 | 5 | 6 | class Alphabet(OrderedEnum): # noqa: D101 7 | A = "a" 8 | B = "b" 9 | C = "c" 10 | 11 | 12 | def test_ordered_enum() -> None: # noqa: D103 13 | assert sorted([Alphabet.C, Alphabet.B, Alphabet.A]) == [Alphabet.A, Alphabet.B, Alphabet.C] 14 | assert tuple(Alphabet) == (Alphabet.A, Alphabet.B, Alphabet.C) 15 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/BigQuery/test_approximate_continuous_percentile_expr__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_approximate_continuous_percentile_expr 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the approximate continuous percentile expression in a query. 5 | sql_engine: BigQuery 6 | --- 7 | -- Test Approximate Continuous Percentile Expression 8 | SELECT 9 | APPROX_QUANTILES(a.col0, 2)[OFFSET(1)] AS col0_percentile 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/BigQuery/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | metric_time__day bookings_join_to_time_spine_with_tiered_filters 5 | ------------------- ------------------------------------------------- 6 | 2020-01-02T00:00:00 9 7 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/DuckDB/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | metric_time__day bookings_join_to_time_spine_with_tiered_filters 5 | ------------------- ------------------------------------------------- 6 | 2020-01-02T00:00:00 9 7 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Postgres/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | metric_time__day bookings_join_to_time_spine_with_tiered_filters 5 | ------------------- ------------------------------------------------- 6 | 2020-01-02T00:00:00 9 7 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Redshift/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | metric_time__day bookings_join_to_time_spine_with_tiered_filters 5 | ------------------- ------------------------------------------------- 6 | 2020-01-02T00:00:00 9 7 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Snowflake/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | METRIC_TIME__DAY BOOKINGS_JOIN_TO_TIME_SPINE_WITH_TIERED_FILTERS 5 | ------------------- ------------------------------------------------- 6 | 2020-01-02T00:00:00 9 7 | -------------------------------------------------------------------------------- /dbt-metricflow/requirements-files/dev-env-requirements.txt: -------------------------------------------------------------------------------- 1 | halo>=0.0.31, <0.1.0 2 | update-checker>=0.18.0, <0.19.0 3 | # Bug with mypy: https://github.com/pallets/click/issues/2558#issuecomment-1656546003 4 | click>=8.1.6 5 | dbt-core>=1.10.4, <1.11.0 6 | dbt-duckdb>=1.8.0, <1.9.0 7 | # Excluding 1.2.1 due to window functions returning incorrect results: 8 | # https://github.com/duckdb/duckdb/issues/16617 9 | # Version 1.4.0 seems to have issues as well, so pinning to <1.4.0 until those are resolved. 10 | duckdb !=1.2.1, <1.4.0 11 | -------------------------------------------------------------------------------- /dbt-metricflow/tests_dbt_metricflow/snapshots/test_output_format.py/str/test_decimals_option_invalid__result.txt: -------------------------------------------------------------------------------- 1 | test_name: test_decimals_option_invalid 2 | test_filename: test_output_format.py 3 | docstring: 4 | Tests the output of `mf query --decimals invalid_value ...`. 5 | expectation_description: 6 | An error should be displayed due to the invalid argument value. 7 | --- 8 | Usage: query [OPTIONS] 9 | Try 'query --help' for help. 10 | 11 | Error: Invalid value for '--decimals': 'invalid_value' is not a valid integer. 12 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/metricflow_semantic_interfaces/implementations/metadata.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantic_interfaces.implementations.base import HashableBaseModel 4 | 5 | 6 | class PydanticFileSlice(HashableBaseModel): # noqa: D101 7 | filename: str 8 | content: str 9 | start_line_number: int 10 | end_line_number: int 11 | 12 | 13 | class PydanticMetadata(HashableBaseModel): # noqa: D101 14 | repo_file_path: str 15 | file_slice: PydanticFileSlice 16 | -------------------------------------------------------------------------------- /metricflow/dataflow/optimizer/dataflow_plan_optimizer.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from abc import ABC, abstractmethod 4 | 5 | from metricflow.dataflow.dataflow_plan import DataflowPlan 6 | 7 | 8 | class DataflowPlanOptimizer(ABC): 9 | """Converts one dataflow plan into another dataflow plan that is more optimal in some way (e.g. performance).""" 10 | 11 | @abstractmethod 12 | def optimize(self, dataflow_plan: DataflowPlan) -> DataflowPlan: # noqa: D102 13 | raise NotImplementedError 14 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_conversion_metrics.py/str/BigQuery/test_conversion_metric_with_different_time_dimension_grains__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_conversion_metric_with_different_time_dimension_grains 2 | test_filename: test_conversion_metrics.py 3 | docstring: 4 | Test query against a conversion metric with a filter that doesn't exist in group by. 5 | --- 6 | visit_buy_conversion_rate_with_monthly_conversion 7 | --------------------------------------------------- 8 | 0.5 9 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_conversion_metrics.py/str/DuckDB/test_conversion_metric_with_different_time_dimension_grains__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_conversion_metric_with_different_time_dimension_grains 2 | test_filename: test_conversion_metrics.py 3 | docstring: 4 | Test query against a conversion metric with a filter that doesn't exist in group by. 5 | --- 6 | visit_buy_conversion_rate_with_monthly_conversion 7 | --------------------------------------------------- 8 | 0.5 9 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_conversion_metrics.py/str/Postgres/test_conversion_metric_with_different_time_dimension_grains__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_conversion_metric_with_different_time_dimension_grains 2 | test_filename: test_conversion_metrics.py 3 | docstring: 4 | Test query against a conversion metric with a filter that doesn't exist in group by. 5 | --- 6 | visit_buy_conversion_rate_with_monthly_conversion 7 | --------------------------------------------------- 8 | 0.5 9 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_conversion_metrics.py/str/Redshift/test_conversion_metric_with_different_time_dimension_grains__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_conversion_metric_with_different_time_dimension_grains 2 | test_filename: test_conversion_metrics.py 3 | docstring: 4 | Test query against a conversion metric with a filter that doesn't exist in group by. 5 | --- 6 | visit_buy_conversion_rate_with_monthly_conversion 7 | --------------------------------------------------- 8 | 0.5 9 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_conversion_metrics.py/str/Snowflake/test_conversion_metric_with_different_time_dimension_grains__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_conversion_metric_with_different_time_dimension_grains 2 | test_filename: test_conversion_metrics.py 3 | docstring: 4 | Test query against a conversion metric with a filter that doesn't exist in group by. 5 | --- 6 | VISIT_BUY_CONVERSION_RATE_WITH_MONTHLY_CONVERSION 7 | --------------------------------------------------- 8 | 0.5 9 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_conversion_metrics.py/str/Trino/test_conversion_metric_with_different_time_dimension_grains__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_conversion_metric_with_different_time_dimension_grains 2 | test_filename: test_conversion_metrics.py 3 | docstring: 4 | Test query against a conversion metric with a filter that doesn't exist in group by. 5 | --- 6 | visit_buy_conversion_rate_with_monthly_conversion 7 | --------------------------------------------------- 8 | 0.5 9 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Databricks/test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_filter_not_in_group_by_using_agg_time_and_metric_time 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | metric_time__day bookings_join_to_time_spine_with_tiered_filters 5 | ------------------- ------------------------------------------------- 6 | 2020-01-02T00:00:00 9 7 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_rewriting_sub_query_reducer.py/SqlPlan/test_rewriting_distinct_select_node_is_not_reduced__after_reducing.sql: -------------------------------------------------------------------------------- 1 | test_name: test_rewriting_distinct_select_node_is_not_reduced 2 | test_filename: test_rewriting_sub_query_reducer.py 3 | docstring: 4 | Tests to ensure distinct select node doesn't get overwritten. 5 | --- 6 | -- test0 7 | SELECT 8 | a.booking_value 9 | FROM ( 10 | -- test1 11 | SELECT DISTINCT 12 | a.booking_value 13 | , a.bookings 14 | FROM demo.fct_bookings a 15 | ) b 16 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_rewriting_sub_query_reducer.py/SqlPlan/test_rewriting_distinct_select_node_is_not_reduced__before_reducing.sql: -------------------------------------------------------------------------------- 1 | test_name: test_rewriting_distinct_select_node_is_not_reduced 2 | test_filename: test_rewriting_sub_query_reducer.py 3 | docstring: 4 | Tests to ensure distinct select node doesn't get overwritten. 5 | --- 6 | -- test0 7 | SELECT 8 | a.booking_value 9 | FROM ( 10 | -- test1 11 | SELECT DISTINCT 12 | a.booking_value 13 | , a.bookings 14 | FROM demo.fct_bookings a 15 | ) b 16 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_conversion_metrics.py/str/Databricks/test_conversion_metric_with_different_time_dimension_grains__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_conversion_metric_with_different_time_dimension_grains 2 | test_filename: test_conversion_metrics.py 3 | docstring: 4 | Test query against a conversion metric with a filter that doesn't exist in group by. 5 | --- 6 | visit_buy_conversion_rate_with_monthly_conversion 7 | --------------------------------------------------- 8 | 0.5 9 | -------------------------------------------------------------------------------- /dbt-metricflow/dbt_metricflow/cli/mf_tutorial_project/models/_models.yml: -------------------------------------------------------------------------------- 1 | # See: https://docs.getdbt.com/docs/build/metricflow-time-spine 2 | # For the page above, be sure to select the correct version of dbt at the top. 3 | 4 | models: 5 | - name: all_days 6 | description: A time spine with one row per day. 7 | time_spine: 8 | standard_granularity_column: date_day # Column for the standard grain of your table 9 | columns: 10 | - name: date_day 11 | granularity: day # Set the granularity of the column 12 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/snapshots/test_suggestions.py/str/test_suggestions_for_metric__result_0.txt: -------------------------------------------------------------------------------- 1 | test_name: test_suggestions_for_metric 2 | test_filename: test_suggestions.py 3 | --- 4 | Got error(s) during query resolution. 5 | 6 | Error #1: 7 | Message: 8 | 9 | The given input does not exactly match any known metrics. 10 | 11 | Suggestions: 12 | ['bookings', 'booking_fees', 'bookings_mom', 'bookings_yoy', 'booking_value', 'booking_payments'] 13 | 14 | Query Input: 15 | 16 | booking 17 | -------------------------------------------------------------------------------- /tests_metricflow/fixtures/source_table_snapshots/multi_hop_join_model/third_hop_table.yaml: -------------------------------------------------------------------------------- 1 | table_snapshot: 2 | table_name: third_hop_table 3 | column_definitions: 4 | - name: customer_third_hop_id 5 | type: STRING 6 | - name: value 7 | type: STRING 8 | - name: third_hop_ds 9 | type: STRING 10 | rows: 11 | - ["another_id0", "citadel", "2020-01-01"] 12 | - ["another_id1", "virtu", "2020-01-02"] 13 | - ["another_id2", "two sigma", "2020-01-03"] 14 | - ["another_id3", "jump", "2020-01-04"] 15 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_dataflow_to_sql_plan.py/SqlPlan/DuckDB/test_filter_node__plan0_optimized.sql: -------------------------------------------------------------------------------- 1 | test_name: test_filter_node 2 | test_filename: test_dataflow_to_sql_plan.py 3 | docstring: 4 | Tests converting a dataflow plan to a SQL query plan where there is a leaf pass filter node. 5 | sql_engine: DuckDB 6 | --- 7 | -- Read Elements From Semantic Model 'bookings_source' 8 | -- Pass Only Elements: ['__bookings'] 9 | SELECT 10 | 1 AS __bookings 11 | FROM ***************************.fct_bookings bookings_source_src_28000 12 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/metricflow_semantic_interfaces/type_enums/dimension_type.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantic_interfaces.enum_extension import ExtendedEnum 4 | 5 | 6 | class DimensionType(ExtendedEnum): 7 | """Determines types of values expected of dimensions.""" 8 | 9 | CATEGORICAL = "categorical" 10 | TIME = "time" 11 | 12 | def is_time_type(self) -> bool: 13 | """Checks if this type of dimension is a time type.""" 14 | return self in [DimensionType.TIME] 15 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_engine_specific_rendering.py/SqlPlan/Redshift/test_approximate_discrete_percentile_expr__plan0.sql: -------------------------------------------------------------------------------- 1 | test_name: test_approximate_discrete_percentile_expr 2 | test_filename: test_engine_specific_rendering.py 3 | docstring: 4 | Tests rendering of the approximate discrete percentile expression in a query. 5 | sql_engine: Redshift 6 | --- 7 | -- Test Approximate Discrete Percentile Expression 8 | SELECT 9 | APPROXIMATE PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY (a.col0)) AS col0_percentile 10 | FROM foo.bar a 11 | -------------------------------------------------------------------------------- /metricflow-semantics/requirements-files/dev-env-requirements.txt: -------------------------------------------------------------------------------- 1 | # Developer tools 2 | mypy>=1.7.0, <1.8.0 3 | pre-commit>=3.2.2, <3.3.0 4 | Pympler >=1.1, <=2.0 5 | pytest-mock>=3.14.0, <3.15.0 6 | pytest-xdist>=3.6.0, <3.7.0 7 | pytest>=8.0.0, < 9.0.0 8 | PyYAML>=6.0, <7.0.0 9 | tabulate>=0.8.9 10 | termcolor>=3.0, <4.0 11 | types-PyYAML 12 | types-python-dateutil 13 | types-tabulate 14 | httpx>=0.24,<0.25 15 | hypothesis>=6.87,<7 16 | isort>=5.12,<6 17 | black>=23.3,<24 18 | pydantic>=1.10,<2 19 | types-Jinja2>=2.11,<3 20 | types-jsonschema>=4.17,<5 21 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/metricflow_semantic_interfaces/naming/keywords.py: -------------------------------------------------------------------------------- 1 | # A double underscore used as a seperator in group by item names. 2 | # e.g. user__country 3 | from __future__ import annotations 4 | 5 | DUNDER = "__" 6 | 7 | # The name for the time dimension used to tabulate / plot metrics. 8 | METRIC_TIME_ELEMENT_NAME = "metric_time" 9 | 10 | 11 | def is_metric_time_name(element_name: str) -> bool: 12 | """Returns True if the given element name corresponds to metric time.""" 13 | return element_name == METRIC_TIME_ELEMENT_NAME 14 | -------------------------------------------------------------------------------- /tests_metricflow/fixtures/source_table_snapshots/multi_hop_join_model/bridge_table.yaml: -------------------------------------------------------------------------------- 1 | table_snapshot: 2 | table_name: bridge_table 3 | column_definitions: 4 | - name: ds_partitioned 5 | type: TIME 6 | - name: account_id 7 | type: STRING 8 | - name: customer_id 9 | type: STRING 10 | - name: extra_dim 11 | type: STRING 12 | rows: 13 | - ["2020-01-01", "a0", "0", "lux"] 14 | - ["2020-01-01", "a1", "2", "not_lux"] 15 | - ["2020-01-02", "a0", "1", "lux"] 16 | - ["2020-01-04", "a2", "3", "super_lux"] 17 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/DuckDB/test_component_rendering__plan2.sql: -------------------------------------------------------------------------------- 1 | test_name: test_component_rendering 2 | test_filename: test_sql_plan_render.py 3 | docstring: 4 | Checks that all components of SELECT query are rendered for the 0, 1, >1 component count cases. 5 | sql_engine: DuckDB 6 | --- 7 | -- test2 8 | SELECT 9 | SUM(1) AS bookings 10 | , b.country AS user__country 11 | , c.country AS listing__country 12 | FROM demo.fct_bookings a 13 | LEFT OUTER JOIN 14 | demo.dim_users b 15 | ON 16 | a.user_id = b.user_id 17 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Trino/test_component_rendering__plan2.sql: -------------------------------------------------------------------------------- 1 | test_name: test_component_rendering 2 | test_filename: test_sql_plan_render.py 3 | docstring: 4 | Checks that all components of SELECT query are rendered for the 0, 1, >1 component count cases. 5 | sql_engine: Trino 6 | --- 7 | -- test2 8 | SELECT 9 | SUM(1) AS bookings 10 | , b.country AS user__country 11 | , c.country AS listing__country 12 | FROM demo.fct_bookings a 13 | LEFT OUTER JOIN 14 | demo.dim_users b 15 | ON 16 | a.user_id = b.user_id 17 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/metricflow_semantic_interfaces/protocols/meta.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from abc import abstractmethod 4 | from typing import Any, Dict, Protocol 5 | 6 | 7 | class SemanticLayerElementConfig(Protocol): # noqa: D101 8 | """The config property allows you to configure additional resources/metadata.""" 9 | 10 | @property 11 | @abstractmethod 12 | def meta(self) -> Dict[str, Any]: # type: ignore[misc] 13 | """The meta field can be used to set metadata for a resource.""" 14 | pass 15 | -------------------------------------------------------------------------------- /metricflow-semantic-interfaces/metricflow_semantic_interfaces/type_enums/aggregation_type.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from metricflow_semantic_interfaces.enum_extension import ExtendedEnum 4 | 5 | 6 | class AggregationType(ExtendedEnum): 7 | """Aggregation methods for measures.""" 8 | 9 | SUM = "sum" 10 | MIN = "min" 11 | MAX = "max" 12 | COUNT_DISTINCT = "count_distinct" 13 | SUM_BOOLEAN = "sum_boolean" 14 | AVERAGE = "average" 15 | PERCENTILE = "percentile" 16 | MEDIAN = "median" 17 | COUNT = "count" 18 | -------------------------------------------------------------------------------- /metricflow-semantics/metricflow_semantics/test_helpers/semantic_manifest_yamls/scd_manifest/scd_users.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | semantic_model: 3 | name: users_latest 4 | description: users_latest 5 | 6 | node_relation: 7 | schema_name: $source_schema 8 | alias: dim_users_latest 9 | 10 | dimensions: 11 | - name: ds 12 | type: time 13 | type_params: 14 | time_granularity: day 15 | - name: home_state_latest 16 | type: categorical 17 | 18 | entities: 19 | - name: user 20 | type: primary 21 | expr: user_id 22 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/BigQuery/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_custom_grain_in_group_by 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | booking__ds__alien_day bookings_join_to_time_spine 5 | ------------------------ ----------------------------- 6 | 2020-01-01T00:00:00 7 | 2020-01-02T00:00:00 31 8 | 2020-01-03T00:00:00 256 9 | 2020-01-04T00:00:00 10 | 2020-01-05T00:00:00 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/DuckDB/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_custom_grain_in_group_by 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | booking__ds__alien_day bookings_join_to_time_spine 5 | ------------------------ ----------------------------- 6 | 2020-01-01T00:00:00 7 | 2020-01-02T00:00:00 31 8 | 2020-01-03T00:00:00 256 9 | 2020-01-04T00:00:00 10 | 2020-01-05T00:00:00 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Postgres/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_custom_grain_in_group_by 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | booking__ds__alien_day bookings_join_to_time_spine 5 | ------------------------ ----------------------------- 6 | 2020-01-01T00:00:00 7 | 2020-01-02T00:00:00 31 8 | 2020-01-03T00:00:00 256 9 | 2020-01-04T00:00:00 10 | 2020-01-05T00:00:00 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Redshift/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_custom_grain_in_group_by 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | booking__ds__alien_day bookings_join_to_time_spine 5 | ------------------------ ----------------------------- 6 | 2020-01-01T00:00:00 7 | 2020-01-02T00:00:00 31 8 | 2020-01-03T00:00:00 256 9 | 2020-01-04T00:00:00 10 | 2020-01-05T00:00:00 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Snowflake/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_custom_grain_in_group_by 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | BOOKING__DS__ALIEN_DAY BOOKINGS_JOIN_TO_TIME_SPINE 5 | ------------------------ ----------------------------- 6 | 2020-01-01T00:00:00 7 | 2020-01-02T00:00:00 31 8 | 2020-01-03T00:00:00 256 9 | 2020-01-04T00:00:00 10 | 2020-01-05T00:00:00 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Trino/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_custom_grain_in_group_by 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | booking__ds__alien_day bookings_join_to_time_spine 5 | ------------------------ ----------------------------- 6 | 2020-01-01T00:00:00 7 | 2020-01-02T00:00:00 31 8 | 2020-01-03T00:00:00 256 9 | 2020-01-04T00:00:00 10 | 2020-01-05T00:00:00 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/BigQuery/test_component_rendering__plan2.sql: -------------------------------------------------------------------------------- 1 | test_name: test_component_rendering 2 | test_filename: test_sql_plan_render.py 3 | docstring: 4 | Checks that all components of SELECT query are rendered for the 0, 1, >1 component count cases. 5 | sql_engine: BigQuery 6 | --- 7 | -- test2 8 | SELECT 9 | SUM(1) AS bookings 10 | , b.country AS user__country 11 | , c.country AS listing__country 12 | FROM demo.fct_bookings a 13 | LEFT OUTER JOIN 14 | demo.dim_users b 15 | ON 16 | a.user_id = b.user_id 17 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Postgres/test_component_rendering__plan2.sql: -------------------------------------------------------------------------------- 1 | test_name: test_component_rendering 2 | test_filename: test_sql_plan_render.py 3 | docstring: 4 | Checks that all components of SELECT query are rendered for the 0, 1, >1 component count cases. 5 | sql_engine: Postgres 6 | --- 7 | -- test2 8 | SELECT 9 | SUM(1) AS bookings 10 | , b.country AS user__country 11 | , c.country AS listing__country 12 | FROM demo.fct_bookings a 13 | LEFT OUTER JOIN 14 | demo.dim_users b 15 | ON 16 | a.user_id = b.user_id 17 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Redshift/test_component_rendering__plan2.sql: -------------------------------------------------------------------------------- 1 | test_name: test_component_rendering 2 | test_filename: test_sql_plan_render.py 3 | docstring: 4 | Checks that all components of SELECT query are rendered for the 0, 1, >1 component count cases. 5 | sql_engine: Redshift 6 | --- 7 | -- test2 8 | SELECT 9 | SUM(1) AS bookings 10 | , b.country AS user__country 11 | , c.country AS listing__country 12 | FROM demo.fct_bookings a 13 | LEFT OUTER JOIN 14 | demo.dim_users b 15 | ON 16 | a.user_id = b.user_id 17 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_fill_nulls_with_0.py/str/Databricks/test_join_to_time_spine_with_custom_grain_in_group_by__query_output.txt: -------------------------------------------------------------------------------- 1 | test_name: test_join_to_time_spine_with_custom_grain_in_group_by 2 | test_filename: test_fill_nulls_with_0.py 3 | --- 4 | booking__ds__alien_day bookings_join_to_time_spine 5 | ------------------------ ----------------------------- 6 | 2020-01-01T00:00:00 7 | 2020-01-02T00:00:00 31 8 | 2020-01-03T00:00:00 256 9 | 2020-01-04T00:00:00 10 | 2020-01-05T00:00:00 11 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Databricks/test_component_rendering__plan2.sql: -------------------------------------------------------------------------------- 1 | test_name: test_component_rendering 2 | test_filename: test_sql_plan_render.py 3 | docstring: 4 | Checks that all components of SELECT query are rendered for the 0, 1, >1 component count cases. 5 | sql_engine: Databricks 6 | --- 7 | -- test2 8 | SELECT 9 | SUM(1) AS bookings 10 | , b.country AS user__country 11 | , c.country AS listing__country 12 | FROM demo.fct_bookings a 13 | LEFT OUTER JOIN 14 | demo.dim_users b 15 | ON 16 | a.user_id = b.user_id 17 | -------------------------------------------------------------------------------- /tests_metricflow/snapshots/test_sql_plan_render.py/SqlPlan/Snowflake/test_component_rendering__plan2.sql: -------------------------------------------------------------------------------- 1 | test_name: test_component_rendering 2 | test_filename: test_sql_plan_render.py 3 | docstring: 4 | Checks that all components of SELECT query are rendered for the 0, 1, >1 component count cases. 5 | sql_engine: Snowflake 6 | --- 7 | -- test2 8 | SELECT 9 | SUM(1) AS bookings 10 | , b.country AS user__country 11 | , c.country AS listing__country 12 | FROM demo.fct_bookings a 13 | LEFT OUTER JOIN 14 | demo.dim_users b 15 | ON 16 | a.user_id = b.user_id 17 | -------------------------------------------------------------------------------- /metricflow-semantics/tests_metricflow_semantics/snapshots/test_messages.py/str/test_long_invalid_metric__result.txt: -------------------------------------------------------------------------------- 1 | test_name: test_long_invalid_metric 2 | test_filename: test_messages.py 3 | docstring: 4 | Test the error message for an empty query. 5 | --- 6 | Got error(s) during query resolution. 7 | 8 | Error #1: 9 | Message: 10 | 11 | The given input does not exactly match any known metrics. 12 | 13 | Suggestions: 14 | ['bookings'] 15 | 16 | Query Input: 17 | 18 | long_invalid_metric_name__________________________________________________ 19 | --------------------------------------------------------------------------------