From 531719f0ea62193b33d978d0e81400462e5117ad Mon Sep 17 00:00:00 2001 From: Will Deng Date: Mon, 4 Dec 2023 14:21:04 -0500 Subject: [PATCH] added fixtures --- .../simple_manifest/metrics.yaml | 39 +++++++++++++++++++ .../semantic_models/buys_source.yaml | 34 ++++++++++++++++ .../semantic_models/visits_source.yaml | 37 ++++++++++++++++++ .../simple_model/fct_buys.yaml | 18 +++++++++ .../simple_model/fct_visits.yaml | 28 +++++++++++++ 5 files changed, 156 insertions(+) create mode 100644 metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/semantic_models/buys_source.yaml create mode 100644 metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/semantic_models/visits_source.yaml create mode 100644 metricflow/test/fixtures/source_table_snapshots/simple_model/fct_buys.yaml create mode 100644 metricflow/test/fixtures/source_table_snapshots/simple_model/fct_visits.yaml diff --git a/metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/metrics.yaml b/metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/metrics.yaml index fcc08c244d..aa226570e0 100644 --- a/metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/metrics.yaml +++ b/metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/metrics.yaml @@ -525,6 +525,45 @@ metric: name: bookings join_to_timespine: true --- +metric: + name: visit_buy_conversion_rate + description: conversion rate on visits-buys on a 7 day window + type: conversion + type_params: + conversion_type_params: + base_measure: visits + conversion_measure: buys + window: 7 days + entity: user + calculation: conversion_rate +--- +metric: + name: visit_buy_conversions + description: conversion count on visits-buys on a 7 day window + type: conversion + type_params: + conversion_type_params: + base_measure: visits + conversion_measure: buys + window: 7 days + entity: user + calculation: conversions +--- +metric: + name: visit_buy_conversion_rate_by_session + description: conversion rate on visits-buys on a 7 day window held by a constant session_id + type: conversion + type_params: + conversion_type_params: + base_measure: visits + conversion_measure: buys + window: 7 days + entity: user + calculation: conversion_rate + constant_properties: + - base_property: session + conversion_property: session_id +--- metric: name: bookings_fill_nulls_with_0_without_time_spine description: Simple metric filling 0 without time spine. Not a commonly expected scenario. diff --git a/metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/semantic_models/buys_source.yaml b/metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/semantic_models/buys_source.yaml new file mode 100644 index 0000000000..fd0eb1d2f2 --- /dev/null +++ b/metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/semantic_models/buys_source.yaml @@ -0,0 +1,34 @@ +--- +semantic_model: + name: buys_source + description: buys_source + + node_relation: + schema_name: $source_schema + alias: fct_buys + + defaults: + agg_time_dimension: ds + + measures: + - name: buys + expr: 1 + agg: count + - name: buyers + expr: user_id + agg: count_distinct + + dimensions: + - name: ds + type: time + type_params: + time_granularity: day + + primary_entity: buy + + entities: + - name: user + type: foreign + expr: user_id + - name: session_id + type: foreign diff --git a/metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/semantic_models/visits_source.yaml b/metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/semantic_models/visits_source.yaml new file mode 100644 index 0000000000..158314f25f --- /dev/null +++ b/metricflow/test/fixtures/semantic_manifest_yamls/simple_manifest/semantic_models/visits_source.yaml @@ -0,0 +1,37 @@ +--- +semantic_model: + name: visits_source + description: visits_source + + node_relation: + schema_name: $source_schema + alias: fct_visits + + defaults: + agg_time_dimension: ds + + measures: + - name: visits + expr: 1 + agg: count + - name: visitors + expr: user_id + agg: count_distinct + + dimensions: + - name: ds + type: time + type_params: + time_granularity: day + - name: referrer_id + type: categorical + + primary_entity: visit + + entities: + - name: user + type: foreign + expr: user_id + - name: session + type: foreign + expr: session_id diff --git a/metricflow/test/fixtures/source_table_snapshots/simple_model/fct_buys.yaml b/metricflow/test/fixtures/source_table_snapshots/simple_model/fct_buys.yaml new file mode 100644 index 0000000000..75e198829c --- /dev/null +++ b/metricflow/test/fixtures/source_table_snapshots/simple_model/fct_buys.yaml @@ -0,0 +1,18 @@ +table_snapshot: + table_name: fct_buys + column_definitions: + - name: ds + type: TIME + - name: user_id + type: STRING + - name: session_id + type: STRING + rows: + - ["2020-01-02", "u0004114", "s1"] + - ["2020-01-03", "u0042324", "s9"] + - ["2020-01-04", "u0005432", "s6"] + - ["2020-01-04", "u0003452", "s7"] + - ["2020-01-07", "u1612112", "s123"] + - ["2020-01-07", "u0004114", "s14"] + - ["2020-01-07", "u0003141", "s3"] + - ["2020-01-10", "u0004117", "s15"] diff --git a/metricflow/test/fixtures/source_table_snapshots/simple_model/fct_visits.yaml b/metricflow/test/fixtures/source_table_snapshots/simple_model/fct_visits.yaml new file mode 100644 index 0000000000..9104d50cc2 --- /dev/null +++ b/metricflow/test/fixtures/source_table_snapshots/simple_model/fct_visits.yaml @@ -0,0 +1,28 @@ +table_snapshot: + table_name: fct_visits + column_definitions: + - name: user_id + type: STRING + - name: ds + type: TIME + - name: referrer_id + type: STRING + - name: session_id + type: STRING + rows: + - ["u0004114", "2020-01-01", "fb_ad_1", "s1"] + - ["u0004214", "2020-01-01", "fb_ad_2", "s2"] + - ["u0003141", "2020-01-01", "homepage_1", "s3"] + - ["u0003154", "2020-01-01", "homepage_2", "s4"] + - ["u1612112", "2020-01-02", "homepage_1", "s5"] + - ["u0005432", "2020-01-02", "fb_ad_3", "s6"] + - ["u0003452", "2020-01-02", "fb_ad_1", "s7"] + - ["u0003452", "2020-01-02", "user_2", "s8"] + - ["u0042324", "2020-01-03", "fb_ad_1", "s9"] + - ["u0005432", "2020-01-03", "google_ad_1", "s10"] + - ["u0005472", "2020-01-03", "google_ad_2", "s11"] + - ["u0005414", "2020-01-04", "google_ad_1", "s12"] + - ["u0004114", "2020-01-06", "homepage_1", "s13"] + - ["u0004114", "2020-01-07", "fb_ad_2", "s14"] + - ["u0004117", "2020-01-10", "google_ad_1", "s15"] + - ["u0003141", "2020-01-12", "user_1", "s16"]