Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update metricflow-commands.md #4426

Merged
merged 5 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions website/docs/docs/build/metricflow-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ Options:
### Validate-configs

This command performs validations against the defined semantic model configurations:
<!--dbt sl validate-configs # In dbt Cloud-->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is redundant for now since as you can run a manifest generating command (dbt parse/build/compile/run) https://docs.getdbt.com/docs/dbt-cloud-apis/sl-manifest#how-its-produced and it would already have done the validations and if that step fails with something about the SL config it means the validations failed.


```bash
dbt sl validate-configs # In dbt Cloud

mf validate-configs # In dbt Core

Expand All @@ -206,20 +206,18 @@ Options:
### Health checks

This command performs a health check against the data platform you provided in the configs:
<!--dbt sl health-checks # In dbt Cloud-->
mirnawong1 marked this conversation as resolved.
Show resolved Hide resolved

```bash
dbt sl health-checks #in dbt Cloud

mf health-checks #in dbt Core
```

### Tutorial

Follow the dedicated MetricFlow tutorial to help you get started:
<!--dbt sl tutorial # In dbt Cloud-->

```bash
dbt sl tutorial # In dbt Cloud

mf tutorial # In dbt Core
```

Expand Down Expand Up @@ -522,7 +520,7 @@ mf query --metrics revenue --group-by metric_time__month # In dbt Core

To add a dimension filter to a where filter, you have to indicate that the filter item is part of your model and use a template wrapper: <code>{{Dimension('primary_entity__dimension_name')}}</code>.

Here's an example query: <code>dbt sl query --metrics order_total --group-by metric_time --where "{{Dimension('order_id__is_food_order')}} = True"</code>.<br /><br /> Before using the template wrapper, however, you will need to set up your terminal to escape curly braces for the filter template to work.
Here's an example query: <code>dbt sl query --metrics order_total --group-by metric_time --where "{{Dimension('order_id__is_food_order')}} = True"</code>.<br /><br /> Before using the template wrapper, however, set up your terminal to escape curly braces for the filter template to work.

<details>
<summary>How to set up your terminal to escape curly braces? </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,15 @@ metrics:

## Query your metric

- It's best practice any time we're updating our semantic layer code to run a `dbt parse && mf validate-configs`.
Use [MetricFlow commands](/docs/build/metricflow-commands#metricflow) for metric validation or queries during development, and apply the following conventions based on your environment:

- For dbt Cloud, use the `dbt sl` prefix before the command (such as, `dbt sl parse` or `dbt sl query`).
mirnawong1 marked this conversation as resolved.
Show resolved Hide resolved
- For dbt Core, use the `mf` prefix (such as `mf validate-configs` or `mf query)`.

Follow these best practices when updating your semantic layer code, using the `mf` command as an example (replace `mf` with `dbt sl` if you're using dbt Cloud):

- It's best practice any time we're updating our semantic layer code to run `dbt parse` if using dbt Cloud or `dbt parse && mf validate-configs` if using dbt Core, to validate your configs.
- If everything passes, we can start querying this metric with `mf query`!
- `mf query` is not how you would use the tool in production, that's handled by the dbt Cloud Semantic Layer's features. It's available for testing results of various metric queries in development, exactly as we're using it now.
- Try `mf query --metrics revenue --group-by metric_time__day` and see a preview of the data come back.
- Note the structure of the above query. We select the metric(s) we want and the dimensions to group them by — we use dunders (double underscores e.g.`metric_time__[time bucket]`) to designate time dimensions or other non-unique dimensions that need a specified entity path to resolve (e.g. if you have a orders location dimension and a employee location dimension both named 'location' you would need dunders to specify `orders__location` or `employee__location`).
- Note the structure of the above query. We select the metric(s) we want and the dimensions to group them by — we use dunders (double underscores e.g.`metric_time__[time bucket]`) to designate time dimensions or other non-unique dimensions that need a specified entity path to resolve (e.g. if you have an orders location dimension and an employee location dimension both named 'location' you would need dunders to specify `orders__location` or `employee__location`).
Loading