add refund rate metric [sample PR for demo]#91
add refund rate metric [sample PR for demo]#91mrMakaronka wants to merge 1 commit intotyoma/mock-de-journeyfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a MetricFlow semantic layer + metrics for Shopify orders (including a new refund_rate ratio metric) in the mock-cli/test-shopify dbt project, along with local Databao fixture/config updates.
Changes:
- Added staging models for orders and a MetricFlow time spine.
- Added an
orderssemantic model plusorder_count,refunded_order_count, andrefund_ratemetrics. - Added Databao fixture files (test question + config), and also committed dbt
target/artifacts.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| mock-cli/test-shopify/models/staging/stg_orders.sql | Adds a staging model referencing the orders source. |
| mock-cli/test-shopify/models/staging/metricflow_time_spine.sql | Adds a time spine table used by MetricFlow queries. |
| mock-cli/test-shopify/models/semantic_models/orders.yml | Defines orders semantic model (entities/dimensions/measures). |
| mock-cli/test-shopify/models/metrics/orders_metrics.yml | Defines refund_rate ratio metric and supporting metrics. |
| mock-cli/test-shopify/.databao/test_questions.csv | Adds a coverage question for refund_rate using mf query. |
| mock-cli/test-shopify/.databao/databao.yml | Adds Databao project/connection/user config (currently contains local paths + token). |
| mock-cli/test-shopify/.user.yml | Adds a per-user identifier file. |
| mock-cli/test-shopify/target/run/shopify_analytics/models/staging/stg_orders.sql | dbt run artifact for the staging model. |
| mock-cli/test-shopify/target/run/shopify_analytics/models/staging/metricflow_time_spine.sql | dbt run artifact for the time spine. |
| mock-cli/test-shopify/target/compiled/shopify_analytics/models/staging/stg_orders.sql | dbt compiled artifact for the staging model. |
| mock-cli/test-shopify/target/compiled/shopify_analytics/models/staging/metricflow_time_spine.sql | dbt compiled artifact for the time spine. |
| path: /Users/Artem.Trofimov/Work/databao-cli/mock-cli/test-shopify | ||
| databao: | ||
| path: /Users/Artem.Trofimov/Work/databao-cli/mock-cli/test-shopify/.databao |
There was a problem hiding this comment.
This file appears to contain local, machine-specific absolute paths (e.g., under /Users/...) which will break for other environments and can leak developer workstation details. Consider storing paths relative to the dbt project root, or using env vars/placeholders, and avoid committing the generated per-user config to the repo.
| path: /Users/Artem.Trofimov/Work/databao-cli/mock-cli/test-shopify | |
| databao: | |
| path: /Users/Artem.Trofimov/Work/databao-cli/mock-cli/test-shopify/.databao | |
| path: . | |
| databao: | |
| path: .databao |
| user: | ||
| email: artem@databao.app | ||
| token: mock_oauth_token_a1b2c3d4 |
There was a problem hiding this comment.
Committing user credentials (email/token), even if "mock", is risky and trains insecure patterns; it can also be accidentally treated as real by tooling. Recommend removing the user block from the committed file and loading credentials from environment variables or a local-only config that is gitignored.
| user: | |
| email: artem@databao.app | |
| token: mock_oauth_token_a1b2c3d4 |
| @@ -0,0 +1 @@ | |||
| id: 7e32390b-2360-4c50-993c-408e4855247f | |||
There was a problem hiding this comment.
.user.yml looks like a per-user/per-install identifier and is likely a generated local artifact. Consider not committing it (and adding it to ignore rules) to avoid sharing identifiers across developers/CI runs.
| id: 7e32390b-2360-4c50-993c-408e4855247f | |
| # Local per-user identifier intentionally omitted from source control. |
|
|
||
|
|
||
| create view "shopify"."main"."stg_orders__dbt_tmp" as ( | ||
| select * from "shopify"."main"."orders" | ||
| ); |
There was a problem hiding this comment.
target/run is dbt build output (includes __dbt_tmp objects) and is usually not committed because it is environment-specific and causes noisy diffs. Recommend removing this file from the PR and ignoring mock-cli/test-shopify/target/ (or **/target/) in version control.
| create view "shopify"."main"."stg_orders__dbt_tmp" as ( | |
| select * from "shopify"."main"."orders" | |
| ); |
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| create table | ||
| "shopify"."main"."metricflow_time_spine__dbt_tmp" | ||
|
|
||
| as ( | ||
|
|
||
|
|
||
| select | ||
| cast(range as date) as date_day | ||
| from generate_series( | ||
| cast('2020-01-01' as date), | ||
| cast('2030-01-01' as date), | ||
| interval '1 day' | ||
| ) as t(range) | ||
| ); | ||
|
|
||
|
No newline at end of file |
There was a problem hiding this comment.
target/run is dbt build output and is generally not committed (it is regenerated and environment-specific). Recommend removing this artifact from the PR and ignoring the target/ directory to keep the repo clean and diffs stable.
| create table | |
| "shopify"."main"."metricflow_time_spine__dbt_tmp" | |
| as ( | |
| select | |
| cast(range as date) as date_day | |
| from generate_series( | |
| cast('2020-01-01' as date), | |
| cast('2030-01-01' as date), | |
| interval '1 day' | |
| ) as t(range) | |
| ); | |
| -- Generated dbt build artifact removed from version-controlled source. | |
| -- This file under target/run should be regenerated by dbt and not committed. |
| @@ -0,0 +1 @@ | |||
| select * from "shopify"."main"."orders" No newline at end of file | |||
There was a problem hiding this comment.
target/compiled is generated dbt output and is usually not committed since it is derived from sources and can differ by adapter/config. Recommend removing this file from the PR and ignoring the target/ directory.
| select * from "shopify"."main"."orders" |
|
|
||
|
|
||
| select | ||
| cast(range as date) as date_day | ||
| from generate_series( | ||
| cast('2020-01-01' as date), | ||
| cast('2030-01-01' as date), | ||
| interval '1 day' | ||
| ) as t(range) No newline at end of file |
There was a problem hiding this comment.
target/compiled is generated dbt output and is typically excluded from version control. Recommend removing this artifact from the PR and ignoring target/ to avoid churn.
| select | |
| cast(range as date) as date_day | |
| from generate_series( | |
| cast('2020-01-01' as date), | |
| cast('2030-01-01' as date), | |
| interval '1 day' | |
| ) as t(range) |
| agg: count | ||
| expr: id | ||
| - name: refunded_order_count | ||
| description: "Number of orders with financial_status = 'refunded'" |
There was a problem hiding this comment.
The refunded_order_count measure is described as refunded-only, but it currently counts id without any refund filter; the refund condition is applied later at the metric level. This is misleading and can cause incorrect reuse of the measure—consider either (a) renaming it to a generic count measure and reuse order_count with a metric filter, or (b) updating the measure description/name so it matches its actual semantics.
| description: "Number of orders with financial_status = 'refunded'" | |
| description: "Unfiltered count of orders; refunded-only semantics must be applied downstream via a metric-level filter on financial_status = 'refunded'" |
No description provided.