forked from dbt-labs/docs.getdbt.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'current' into dbt-teradata-1.8.x
- Loading branch information
Showing
71 changed files
with
1,257 additions
and
912 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 13 additions & 49 deletions
62
website/docs/best-practices/how-we-build-our-metrics/semantic-layer-2-setup.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,26 @@ | ||
--- | ||
title: "Set up MetricFlow" | ||
description: Getting started with the dbt and MetricFlow | ||
hoverSnippet: Learn how to get started with the dbt and MetricFlow | ||
title: "Set up the dbt Semantic Layer" | ||
description: Getting started with the dbt Semantic Layer | ||
hoverSnippet: Learn how to get started with the dbt Semantic Layer | ||
pagination_next: "best-practices/how-we-build-our-metrics/semantic-layer-3-build-semantic-models" | ||
--- | ||
|
||
## Getting started | ||
|
||
First, if you want to follow along, we'll need to clone the [example project](https://github.com/dbt-labs/jaffle-sl-template). You will need access to a Snowflake, BigQuery, Databricks, or Postgres warehouse for this, for the time being. The project is our classic Jaffle Shop, a simulated chain restaurant serving [jaffles](https://en.wikipedia.org/wiki/Pie_iron) and tasty beverages. | ||
There are two options for developing a dbt project, including the Semantic Layer: | ||
|
||
```shell | ||
git clone [email protected]:dbt-labs/jaffle-sl-template.git | ||
cd path/to/project | ||
``` | ||
- [dbt Cloud CLI](/docs/cloud/cloud-cli-installation) — MetricFlow commands are embedded in the dbt Cloud CLI under the `dbt sl` subcommand. This is the easiest, most full-featured way to develop dbt Semantic Layer code for the time being. You can use the editor of your choice and run commands from the terminal. | ||
|
||
Next, before you start writing code, you need to install MetricFlow: | ||
- [dbt Cloud IDE](/docs/cloud/dbt-cloud-ide/develop-in-the-cloud) — You can create semantic models and metrics in the dbt Cloud IDE. However, support for running `dbt sl` commands isn't available just yet, but is in active development. This means you won't be able to validate your code, so we'd recommend working with the Cloud CLI and a local editor for now. | ||
|
||
<Tabs> | ||
|
||
<TabItem value="cloud" label="dbt Cloud"> | ||
|
||
- [dbt Cloud CLI](/docs/cloud/cloud-cli-installation) — MetricFlow commands are embedded in the dbt Cloud CLI. You can immediately run them once you install the dbt Cloud CLI. Using dbt Cloud means you won't need to manage versioning — your dbt Cloud account will automatically manage the versioning. | ||
|
||
- [dbt Cloud IDE](/docs/cloud/dbt-cloud-ide/develop-in-the-cloud) — You can create metrics using MetricFlow in the dbt Cloud IDE. However, support for running MetricFlow commands in the IDE will be available soon. | ||
|
||
</TabItem> | ||
|
||
<TabItem value="core" label="dbt Core"> | ||
|
||
- Download MetricFlow as an extension of a dbt adapter from PyPI (dbt Core users only). The MetricFlow is compatible with Python versions 3.8 through 3.11. | ||
- **Note**: You'll need to manage versioning between dbt Core, your adapter, and MetricFlow. | ||
- Beginning in v1.8, installing an adapter does not automatically install `dbt-core`. This is because adapters and dbt Core versions have been decoupled from each other so we no longer want to overwrite existing dbt-core installations. | ||
- Use pip to install MetricFlow and the dbt adapter. | ||
|
||
```shell | ||
# activate a virtual environment for your project, | ||
# if you don't have a name you like to use we suggest .venv | ||
python -m venv [virtual environment name] | ||
source [virtual environment name]/bin/activate | ||
# install dbt and MetricFlow | ||
python -m pip install "dbt-metricflow[adapter name]" | ||
# e.g. python -m pip install "dbt-metricflow[snowflake]" | ||
``` | ||
|
||
</TabItem> | ||
</Tabs> | ||
|
||
- Now that you're ready to use MetricFlow, get to the pre-Semantic Layer starting state by checking out the `start-here` branch: | ||
## Basic commands | ||
|
||
```shell | ||
git checkout start-here | ||
``` | ||
- 🔍 A less common command that will come in handy with the Semantic Layer is `dbt parse`. This will parse your project and generate a **semantic manifest**, a representation of meaningful connections described by your project. This is uploaded to dbt Cloud, and used for running `dbt sl` commands in development. This file gives MetricFlow a **state of the world from which to generate queries**. | ||
- 🧰 `dbt sl query` is your other best friend, it will execute a query against your semantic layer and return a sample of the results. This is great for testing your semantic models and metrics as you build them. For example, if you're building a revenue model you can run `dbt sl query revenue --group-by metric_time__month` to validate that monthly revenue is calculating correctly. | ||
- 📝 Lastly, `dbt sl list dimensions --metrics [metric name]` will list all the dimensions available for a given metric. This is useful for checking that you're increasing dimensionality as you progress. You can `dbt sl list` other aspects of your Semantic Layer as well, run `dbt sl list --help` for the full list of options. | ||
|
||
For more information, refer to the [MetricFlow commands](/docs/build/metricflow-commands) or the [quickstart guides](/guides) to get more familiar with setting up a dbt project. | ||
For more information on the available commands, refer to the [MetricFlow commands](/docs/build/metricflow-commands) reference, or use `dbt sl --help` and `dbt sl [subcommand] --help` on the command line. If you need to set up a dbt project first, check out the [quickstart guides](/docs/get-started-dbt). | ||
|
||
## Basic commands | ||
## Onward! | ||
|
||
- 💻 This package will install both `dbt` and `mf` as CLIs in our virtual environment. All the regular `dbt` commands like `run`, `build`, and `test` are available. | ||
- 🔍 A less common one that will come in handy with the Semantic Layer is `dbt parse`. This will parse your project and generate a **semantic manifest**, a representation of meaningful connections described by your project. This file gives MetricFlow a **state of the world from which to generate queries**. | ||
- 🧰 In addition to `dbt`, you'll have access to `mf` commands like `query` and `validate-configs`, which operate based on that semantic manifest. We'll dig more into all of these as we go along. | ||
- 🛠️ Lets start off by running a `dbt build` to get the **starting state** of our project built. | ||
Throughout the rest of the guide, we'll show example code based on the Jaffle Shop project, a fictional chain of restaurants. You can check out the code yourself and try things out in the [Jaffle Shop repository](https://github.com/dbt-labs/jaffle-shop). So if you see us calculating metrics like `food_revenue` later in this guide, this is why! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.