From c8a2b0b861b8d2c650c9fbb9558c27e2391111b8 Mon Sep 17 00:00:00 2001 From: Dave Connors Date: Thu, 23 May 2024 14:50:30 -0500 Subject: [PATCH] updates --- schemas/latest/dbt_yml_files-latest.json | 76 ++++++++++++++++++------ tests/latest/invalid/dbt_yml_files.yml | 60 +++++++++++++++++++ tests/latest/valid/dbt_yml_files.yml | 42 +++++++++++++ 3 files changed, 161 insertions(+), 17 deletions(-) diff --git a/schemas/latest/dbt_yml_files-latest.json b/schemas/latest/dbt_yml_files-latest.json index 76e12f9..e8ecbdb 100644 --- a/schemas/latest/dbt_yml_files-latest.json +++ b/schemas/latest/dbt_yml_files-latest.json @@ -346,6 +346,9 @@ }, "label": { "type": "string" + }, + "type_params": { + "type": "object" } }, "additionalProperties": false @@ -365,9 +368,6 @@ "description": { "type": "string" }, - "deprecation_date": { - "type": "string" - }, "access": { "type": "string", "enum": [ @@ -394,6 +394,9 @@ "$ref": "#/$defs/data_tests" } }, + "deprecation_date": { + "type": "string" + }, "docs": { "$ref": "#/$defs/docs_config" }, @@ -1129,20 +1132,59 @@ "conversion_metric_type_params": { "type": "object", "properties": { - "measure": { - "$ref": "#/$defs/metric_input_measure" - }, - "metrics": { - "type": "array", - "items": { - "$ref": "#/$defs/metric_input_schema" - } - }, - "numerator": { - "$ref": "#/$defs/metric_input_measure" - }, - "window": { - "type": "string" + "conversion_type_params": { + "type": "object", + "required": [ + "entity", + "base_measure", + "conversion_measure" + ], + "properties": { + "base_measure": { + "$ref": "#/$defs/metric_input_measure" + }, + "calculation": { + "type": "string", + "default": "conversion_rate", + "enum": [ + "conversions", + "conversion_rate", + "CONVERSIONS", + "CONVERSION_RATE" + ] + }, + "constant_properties": { + "type": "array", + "items": { + "type": "object", + "required": [ + "base_property", + "conversion_property" + ], + "properties": { + "base_property": { + "description": "DIMENSION or ENTITY", + "type": "string" + }, + "conversion_property": { + "description": "DIMENSION or ENTITY", + "type": "string" + } + } + } + }, + "conversion_measure": { + "$ref": "#/$defs/metric_input_measure" + }, + "entity": { + "description": "The entity to calculate over", + "type": "string" + }, + "window": { + "type": "string" + } + }, + "additionalProperties": false } }, "additionalProperties": false diff --git a/tests/latest/invalid/dbt_yml_files.yml b/tests/latest/invalid/dbt_yml_files.yml index 309909f..6539f4e 100644 --- a/tests/latest/invalid/dbt_yml_files.yml +++ b/tests/latest/invalid/dbt_yml_files.yml @@ -66,6 +66,66 @@ metrics: calculation_method: derived expression: "{{ metric('new_customers') }} * 2" + - name: new_customer + description: Unique count of new customers. + label: New Customers + type: simple + type_params: + measure: + name: customers_with_orders + metrics: + - name: order_total + alias: revenue + filter: | + {{ Dimension('order__is_food_order') }} = True + window: 1 month + filter: | + {{ Dimension('customer__customer_type') }} = 'new' + + - name: food_order_gross_profit + label: Food order gross profit + description: "The gross profit for each food order." + type: derived + type_params: + expr: revenue - cost + measure: + name: customers_with_orders + metrics: + - name: order_total + alias: revenue + filter: | + {{ Dimension('order__is_food_order') }} = True + - name: order_cost + alias: cost + filter: | + {{ Dimension('order__is_food_order') }} = True + + - name: cumulative_order_total_l1m + label: Cumulative Order total (L1M) + description: Trailing 1-month cumulative order amount + type: joel + type_params: + measure: + name: order_total + fill_nulls_with: 0 + window: 1 month + + - name: visit_to_buy_conversion_rate_7_day_window + description: "Conversion rate from viewing a page to making a purchase" + type: conversion + label: Visit to Seller Conversion Rate (7 day window) + type_params: + conversion_type_params: + expr: revenue - cost + calculation: conversions + base_measure: + name: visits + conversion_measure: + name: buys + fill_nulls_with: 0 + entity: user + window: 7 days + unit_tests: - name: some_unit_test diff --git a/tests/latest/valid/dbt_yml_files.yml b/tests/latest/valid/dbt_yml_files.yml index f05c703..a1c5c87 100644 --- a/tests/latest/valid/dbt_yml_files.yml +++ b/tests/latest/valid/dbt_yml_files.yml @@ -185,6 +185,7 @@ metrics: name: customers_with_orders fill_nulls_with: 0 join_to_timespine: true + - name: new_customer description: Unique count of new customers. label: New Customers @@ -209,6 +210,47 @@ metrics: filter: | "{{ Dimension('transaction__location') }} = 'US'" + - name: food_order_gross_profit + label: Food order gross profit + description: "The gross profit for each food order." + type: derived + type_params: + expr: revenue - cost + metrics: + - name: order_total + alias: revenue + filter: | + {{ Dimension('order__is_food_order') }} = True + - name: order_cost + alias: cost + filter: | + {{ Dimension('order__is_food_order') }} = True + + - name: cumulative_order_total_l1m + label: Cumulative Order total (L1M) + description: Trailing 1-month cumulative order amount + type: cumulative + type_params: + measure: + name: order_total + fill_nulls_with: 0 + window: 1 month + + - name: visit_to_buy_conversion_rate_7_day_window + description: "Conversion rate from viewing a page to making a purchase" + type: conversion + label: Visit to Seller Conversion Rate (7 day window) + type_params: + conversion_type_params: + calculation: conversions + base_measure: + name: visits + conversion_measure: + name: buys + fill_nulls_with: 0 + entity: user + window: 7 days + saved_queries: - name: test_saved_query description: "{{ doc('saved_query_description') }}"