From 570baf4ec5ed31884e4e6c5daa8fbfb2c5edd27a Mon Sep 17 00:00:00 2001 From: Mirna Wong <89008547+mirnawong1@users.noreply.github.com> Date: Mon, 30 Sep 2024 22:09:32 +0100 Subject: [PATCH 1/7] Update metricflow-commands.md updating query examples to include missing primary entity prefix in group by command [refer to slack thread](https://dbt-labs.slack.com/archives/C04REFN03MX/p1727728803420059) --- website/docs/docs/build/metricflow-commands.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/website/docs/docs/build/metricflow-commands.md b/website/docs/docs/build/metricflow-commands.md index 383b6680261..a3c5d0d6c4d 100644 --- a/website/docs/docs/build/metricflow-commands.md +++ b/website/docs/docs/build/metricflow-commands.md @@ -338,13 +338,13 @@ mf query --metrics order_total,users_active --group-by metric_time # In dbt Core -You can include multiple dimensions in a query. For example, you can group by the `is_food_order` dimension to confirm if orders were for food or not. +You can include multiple dimensions in a query. For example, you can group by the `is_food_order` dimension to confirm if orders were for food or not. Note that when you query a dimension, you need to specify the primary entity for that dimension. **Query** ```bash -dbt sl query --metrics order_total --group-by metric_time,is_food_order # In dbt Cloud +dbt sl query --metrics order_total --group-by primary_entity__is_food_order # In dbt Cloud -mf query --metrics order_total --group-by metric_time,is_food_order # In dbt Core +mf query --metrics order_total --group-by primary_entity__is_food_order # In dbt Core ``` **Result** @@ -368,13 +368,15 @@ mf query --metrics order_total --group-by metric_time,is_food_order # In dbt Cor You can add order and limit functions to filter and present the data in a readable format. The following query limits the data set to 10 records and orders them by `metric_time`, descending. Note that using the `-` prefix will sort the query in descending order. Without the `-` prefix sorts the query in ascending order. +Note that when you query a dimension, you need to specify the primary entity for that dimension. + **Query** ```bash # In dbt Cloud -dbt sl query --metrics order_total --group-by metric_time,is_food_order --limit 10 --order-by -metric_time +dbt sl query --metrics order_total --group-by primary_entity__is_food_order --limit 10 --order-by -metric_time # In dbt Core -mf query --metrics order_total --group-by metric_time,is_food_order --limit 10 --order-by -metric_time +mf query --metrics order_total --group-byprimary_entity__is_food_order --limit 10 --order-by -metric_time ``` **Result** @@ -428,16 +430,16 @@ mf query --metrics order_total --group-by metric_time --where "{{ Dimension('ord To filter by time, there are dedicated start and end time options. Using these options to filter by time allows MetricFlow to further optimize query performance by pushing down the where filter when appropriate. - +Note that when you query a dimension, you need to specify the primary entity for that dimension. **Query** ```bash # In dbt Core -mf query --metrics order_total --group-by metric_time,is_food_order --limit 10 --order-by -metric_time --where "is_food_order = True" --start-time '2017-08-22' --end-time '2017-08-27' +mf query --metrics order_total --group-by primary_entity__is_food_order --limit 10 --order-by -metric_time --where "is_food_order = True" --start-time '2017-08-22' --end-time '2017-08-27' ``` **Result** From fda36a30202bd38172258e39b2751c8bb7cdc7cd Mon Sep 17 00:00:00 2001 From: Mirna Wong <89008547+mirnawong1@users.noreply.github.com> Date: Mon, 30 Sep 2024 22:15:40 +0100 Subject: [PATCH 2/7] Update metricflow-commands.md --- website/docs/docs/build/metricflow-commands.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/docs/docs/build/metricflow-commands.md b/website/docs/docs/build/metricflow-commands.md index a3c5d0d6c4d..8e9438fa0ba 100644 --- a/website/docs/docs/build/metricflow-commands.md +++ b/website/docs/docs/build/metricflow-commands.md @@ -396,15 +396,15 @@ mf query --metrics order_total --group-byprimary_entity__is_food_order --limit 1 -You can further filter the data set by adding a `where` clause to your query. The following example shows you how to query the `order_total` metric, grouped by `metric_time` with multiple where statements (orders that are food orders and orders from the week starting on or after Feb 1st, 2024): +You can further filter the data set by adding a `where` clause to your query. The following example shows you how to query the `order_total` metric, grouped by `is_food_order` with multiple where statements (orders that are food orders and orders from the week starting on or after Feb 1st, 2024). Note that when you query a dimension, you need to specify the primary entity for that dimension. In the following example, the primary entity is `order_id`. **Query** ```bash # In dbt Cloud -dbt sl query --metrics order_total --group-by metric_time --where "{{ Dimension('order_id__is_food_order') }} = True and metric_time__week >= '2024-02-01'" +dbt sl query --metrics order_total --group-by order_id__is_food_order --where "{{ Dimension('order_id__is_food_order') }} = True and metric_time__week >= '2024-02-01'" # In dbt Core -mf query --metrics order_total --group-by metric_time --where "{{ Dimension('order_id__is_food_order') }} = True and metric_time__week >= '2024-02-01'" +mf query --metrics order_total --group-by order_id__is_food_order --where "{{ Dimension('order_id__is_food_order') }} = True and metric_time__week >= '2024-02-01'" ``` **Result** From 0d1cdc8086a7ee81781db7e4b63fd0fa12db17f8 Mon Sep 17 00:00:00 2001 From: Mirna Wong <89008547+mirnawong1@users.noreply.github.com> Date: Mon, 30 Sep 2024 22:15:56 +0100 Subject: [PATCH 3/7] Update website/docs/docs/build/metricflow-commands.md --- website/docs/docs/build/metricflow-commands.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/docs/build/metricflow-commands.md b/website/docs/docs/build/metricflow-commands.md index 8e9438fa0ba..f46393d7f5e 100644 --- a/website/docs/docs/build/metricflow-commands.md +++ b/website/docs/docs/build/metricflow-commands.md @@ -376,7 +376,7 @@ Note that when you query a dimension, you need to specify the primary entity for dbt sl query --metrics order_total --group-by primary_entity__is_food_order --limit 10 --order-by -metric_time # In dbt Core -mf query --metrics order_total --group-byprimary_entity__is_food_order --limit 10 --order-by -metric_time +mf query --metrics order_total --group-by primary_entity__is_food_order --limit 10 --order-by -metric_time ``` **Result** From fc5ac6cb6634f52a4358940afc4d5885a830ea1b Mon Sep 17 00:00:00 2001 From: Mirna Wong <89008547+mirnawong1@users.noreply.github.com> Date: Mon, 30 Sep 2024 22:16:22 +0100 Subject: [PATCH 4/7] Update website/docs/docs/build/metricflow-commands.md --- website/docs/docs/build/metricflow-commands.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/docs/build/metricflow-commands.md b/website/docs/docs/build/metricflow-commands.md index f46393d7f5e..7dabfa37cf4 100644 --- a/website/docs/docs/build/metricflow-commands.md +++ b/website/docs/docs/build/metricflow-commands.md @@ -342,7 +342,7 @@ You can include multiple dimensions in a query. For example, you can group by th **Query** ```bash -dbt sl query --metrics order_total --group-by primary_entity__is_food_order # In dbt Cloud +dbt sl query --metrics order_total --group-by order_id__is_food_order # In dbt Cloud mf query --metrics order_total --group-by primary_entity__is_food_order # In dbt Core ``` From 79366bec41926445640967577bdf932560be6888 Mon Sep 17 00:00:00 2001 From: Mirna Wong <89008547+mirnawong1@users.noreply.github.com> Date: Mon, 30 Sep 2024 22:16:47 +0100 Subject: [PATCH 5/7] Update website/docs/docs/build/metricflow-commands.md --- website/docs/docs/build/metricflow-commands.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/docs/build/metricflow-commands.md b/website/docs/docs/build/metricflow-commands.md index 7dabfa37cf4..40cbf8a77ca 100644 --- a/website/docs/docs/build/metricflow-commands.md +++ b/website/docs/docs/build/metricflow-commands.md @@ -344,7 +344,7 @@ You can include multiple dimensions in a query. For example, you can group by th ```bash dbt sl query --metrics order_total --group-by order_id__is_food_order # In dbt Cloud -mf query --metrics order_total --group-by primary_entity__is_food_order # In dbt Core +mf query --metrics order_total --group-by order_id__is_food_order # In dbt Core ``` **Result** From 4fdd6441356faabfcebd370d6ac35cc93380bd2d Mon Sep 17 00:00:00 2001 From: Mirna Wong <89008547+mirnawong1@users.noreply.github.com> Date: Mon, 30 Sep 2024 22:16:57 +0100 Subject: [PATCH 6/7] Update website/docs/docs/build/metricflow-commands.md --- website/docs/docs/build/metricflow-commands.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/docs/build/metricflow-commands.md b/website/docs/docs/build/metricflow-commands.md index 40cbf8a77ca..9120e9ccef9 100644 --- a/website/docs/docs/build/metricflow-commands.md +++ b/website/docs/docs/build/metricflow-commands.md @@ -338,7 +338,7 @@ mf query --metrics order_total,users_active --group-by metric_time # In dbt Core -You can include multiple dimensions in a query. For example, you can group by the `is_food_order` dimension to confirm if orders were for food or not. Note that when you query a dimension, you need to specify the primary entity for that dimension. +You can include multiple dimensions in a query. For example, you can group by the `is_food_order` dimension to confirm if orders were for food or not. Note that when you query a dimension, you need to specify the primary entity for that dimension. In the following example, the primary entity is `order_id`. **Query** ```bash From 80ddce5619939673e6aa098fa81c8ab936bee558 Mon Sep 17 00:00:00 2001 From: Mirna Wong <89008547+mirnawong1@users.noreply.github.com> Date: Mon, 30 Sep 2024 22:29:56 +0100 Subject: [PATCH 7/7] Update metricflow-commands.md --- website/docs/docs/build/metricflow-commands.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/website/docs/docs/build/metricflow-commands.md b/website/docs/docs/build/metricflow-commands.md index 9120e9ccef9..d9e01bede71 100644 --- a/website/docs/docs/build/metricflow-commands.md +++ b/website/docs/docs/build/metricflow-commands.md @@ -368,15 +368,15 @@ mf query --metrics order_total --group-by order_id__is_food_order # In dbt Core You can add order and limit functions to filter and present the data in a readable format. The following query limits the data set to 10 records and orders them by `metric_time`, descending. Note that using the `-` prefix will sort the query in descending order. Without the `-` prefix sorts the query in ascending order. -Note that when you query a dimension, you need to specify the primary entity for that dimension. + Note that when you query a dimension, you need to specify the primary entity for that dimension. In the following example, the primary entity is `order_id`. **Query** ```bash # In dbt Cloud -dbt sl query --metrics order_total --group-by primary_entity__is_food_order --limit 10 --order-by -metric_time +dbt sl query --metrics order_total --group-by order_id__is_food_order --limit 10 --order-by -metric_time # In dbt Core -mf query --metrics order_total --group-by primary_entity__is_food_order --limit 10 --order-by -metric_time +mf query --metrics order_total --group-by order_id__is_food_order --limit 10 --order-by -metric_time ``` **Result** @@ -430,16 +430,16 @@ mf query --metrics order_total --group-by order_id__is_food_order --where "{{ Di To filter by time, there are dedicated start and end time options. Using these options to filter by time allows MetricFlow to further optimize query performance by pushing down the where filter when appropriate. -Note that when you query a dimension, you need to specify the primary entity for that dimension. + Note that when you query a dimension, you need to specify the primary entity for that dimension. In the following example, the primary entity is `order_id`. **Query** ```bash # In dbt Core -mf query --metrics order_total --group-by primary_entity__is_food_order --limit 10 --order-by -metric_time --where "is_food_order = True" --start-time '2017-08-22' --end-time '2017-08-27' +mf query --metrics order_total --group-by order_id__is_food_order --limit 10 --order-by -metric_time --where "is_food_order = True" --start-time '2017-08-22' --end-time '2017-08-27' ``` **Result**