Skip to content

Commit

Permalink
Merge branch 'current' into thorn14-patch-deploy-jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
nghi-ly authored Sep 7, 2023
2 parents 421a8bf + 97cedc9 commit 4a98f84
Show file tree
Hide file tree
Showing 17 changed files with 338 additions and 294 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ body:
label: Additional information
description: Add any other context or screenshots about the feature request here.
validations:
required: false
required: false
3 changes: 0 additions & 3 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: Want to see new content? Open a discussion!
url: https://github.com/dbt-labs/docs.getdbt.com/discussions/new
about: You can open a discussion to propose new content for the dbt product documentation.
- name: Have questions about dbt? Join the Community!
url: https://www.getdbt.com/community/join-the-community
about: You can join the dbt Labs Community to ask and answer questions.
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/improve-the-site.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Improve the docs.getdbt.com site
description: Make a suggestion or report a problem about the technical implementation of docs.getdbt.com.
labels: ["engineering"]
name: Report a docs.getdbt.com site issue
description: Report a problem about the technical implementation of docs.getdbt.com.
labels: ["engineering","bug"]
body:
- type: markdown
attributes:
Expand Down Expand Up @@ -39,4 +39,4 @@ body:
label: Additional information
description: Any additional information, configuration, or data that might be necessary to reproduce the issue.
validations:
required: false
required: false
33 changes: 0 additions & 33 deletions .github/ISSUE_TEMPLATE/new-dbt-feature.yml

This file was deleted.

31 changes: 24 additions & 7 deletions .github/ISSUE_TEMPLATE/zzz_add-adapter-to-trusted-list.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name: Add adapter to Trusted list
description: >
For adapter maintainers who wish to have theirs added to the list of [Trusted adapters](https://docs.getdbt.com/docs/trusted-adapters)
description: For adapter maintainers who wish to have theirs added to the list of Trusted adapters.
title: "Trust dbt-myadapter"
labels: ["adapter maintainers"]
assignees:
- dataders
body:
- type: markdown
attributes:
value: |
We're excited that you'd like to support your adapter formally as "Trusted"! This template will ensure that you are aware of the process and the guidelines. Additionally, that you can vouch that your adapter currently meets the standards of a Trusted adapter
We're excited that you'd like to support your adapter formally as "Trusted"! This template will ensure that you are aware of the process and the guidelines. Additionally, that you can vouch that your adapter currently meets the standards of a Trusted adapter. For more information, see [Trusted adapters](https://docs.getdbt.com/docs/trusted-adapters)
- type: input
id: adapter-repo
Expand All @@ -25,21 +27,36 @@ body:
validations:
required: true

- type: checkboxes
- type: dropdown
id: author_type
attributes:
label: Which of these best describes you?
options:
- label: I am a dbt Community member
- label: I work for the vendor on top of which the dbt adapter functions
- I am a dbt Community member
- I work for the vendor on top of which the dbt adapter functions
validations:
required: true

- type: checkboxes
id: read-program-guide
attributes:
label: Please agree to the each of the following
options:
- label: I am a maintainer of the adapter being submited for Trusted status
required: true
- label: I have read both the [Trusted adapters](https://docs.getdbt.com/docs/trusted-adapters) and [Building a Trusted Adapter](https://docs.getdbt.com/guides/dbt-ecosystem/adapter-development/8-building-a-trusted-adapter) pages.
required: true
- label: I believe that the adapter currently meets the expectations given above
- label: I will ensure this adapter stays in compliance with the guidelines
required: true
- label: I will ensure this adapter stays in compliance with the guidelines
required: true
- label: I understand that dbt Labs reserves the right to remove an adapter from the trusted adapter list at any time, should any of the below guidelines not be met
required: true

- type: textarea
id: icon
attributes:
label: What icon should be used?
description: |
Please share an svg image that you'd like to be displayed in for your adapter. Normally, this is the logo for the data platform on top of which your adapter works. If there's a dark mode version, please also share that.
Pasting the image from your clipboard will upload the file to GitHub and create markdown formatting for it to be rendered inline
78 changes: 68 additions & 10 deletions website/docs/docs/build/derived-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar_label: Derived
tags: [Metrics, Semantic Layer]
---

In MetricFlow, derived metrics are metrics created by defining an expression using other metrics. They allow performing calculations on top of existing metrics. This proves useful for combining metrics and applying arithmetic functions to aggregated columns, such as, you can define a profit metric.
In MetricFlow, derived metrics are metrics created by defining an expression using other metrics. They enable you to perform calculations with existing metrics. This is helpful for combining metrics and doing math functions on aggregated columns, like creating a profit metric.

The parameters, description, and type for derived metrics are:

Expand All @@ -21,7 +21,7 @@ In MetricFlow, derived metrics are metrics created by defining an expression usi
| `metrics` | The list of metrics used in the derived metrics. | Required |
| `alias` | Optional alias for the metric that you can use in the expr. | Optional |
| `filter` | Optional filter to apply to the metric. | Optional |
| `offset_window` | Set the period for the offset window, such as 1 month. This will return the value of the metric one month from the metric time. | Required |
| `offset_window` | Set the period for the offset window, such as 1 month. This will return the value of the metric one month from the metric time. This can't be used with `offset_to_grain`. | Required |

The following displays the complete specification for derived metrics, along with an example.

Expand All @@ -37,7 +37,7 @@ metrics:
- name: the name of the metrics. must reference a metric you have already defined # Required
alias: optional alias for the metric that you can use in the expr # Optional
filter: optional filter to apply to the metric # Optional
offset_window: set the period for the offset window i.e 1 month. This will return the value of the metric one month from the metric time. # Required
offset_window: set the period for the offset window, such as 1 month. This will return the value of the metric one month from the metric time. # Required
```
## Derived metrics example
Expand Down Expand Up @@ -85,17 +85,75 @@ metrics:
## Derived metric offset
You may want to use an offset value of a metric in the definition of a derived metric. For example, you can model the retention rate by using a derived metric with an offset, which involves calculating (active customers at the end of the month/active customers at the beginning of the month).
To perform calculations using a metric's value from a previous time period, you can add an offset parameter to a derived metric. For example, if you want to calculate period-over-period growth or track user retention, you can use this metric offset.
**Note:** You must include the [`metric_time` dimension](/docs/build/dimensions#time) when querying a derived metric with an offset window.

The following example displays how you can calculate monthly revenue growth using a 1-month offset window:

```yaml
metrics:
- name: user_retention
type: derived
- name: customer_retention
description: Percentage of customers that are active now and those active 1 month ago
label: customer_retention
type_params:
expr: active_customers/active_customers_t1m
expr: (active_customers/ active_customers_prev_month)
metrics:
- name: active_customers # these are all metrics (can be a derived metric, meaning building a derived metric with derived metrics)
- name: active_customers
alias: current_active_customers
- name: active_customers
offset_window: 1 month
alias: active_customers_t1m
alias: active_customers_prev_month
```

### Offset windows and granularity

You can query any granularity and offset window combination. The following example queries a metric with a 7-day offset and a monthly grain:

```yaml
- name: d7_booking_change
description: Difference between bookings now and 7 days ago
type: derived
label: d7 Bookings Change
type_params:
expr: bookings - bookings_7_days_ago
metrics:
- name: bookings
alias: current_bookings
- name: bookings
offset_window: 7 days
alias: bookings_7_days_ago
```

When you run the query `mf query --metrics d7_booking_change --group-by metric_time__month` for the metric, here's how it's calculated:

1. We retrieve the raw, unaggregated dataset with the specified measures and dimensions at the smallest level of detail, which is currently 'day'.
2. Then, we perform an offset join on the daily dataset, followed by performing a date trunc and aggregation to the requested granularity.
For example, to calculate `d7_booking_change` for July 2017:
- First, we sum up all the booking values for each day in July to calculate the bookings metric.
- The following table displays the range of days that make up this monthly aggregation.

| | Orders | Metric_time |
| - | ---- | -------- |
| | 330 | 2017-07-31 |
| | 7030 | 2017-07-30 to 2017-07-02 |
| | 78 | 2017-07-01 |
| Total | 7438 | 2017-07-01 |

3. Next, we calculate July's bookings with a 7-day offset. The following table displays the range of days that make up this monthly aggregation. Note that the month begins 7 days later (offset by 7 days) on 2017-07-24.

| | Orders | Metric_time |
| - | ---- | -------- |
| | 329 | 2017-07-24 |
| | 6840 | 2017-07-23 to 2017-06-30 |
| | 83 | 2017-06-24 |
| Total | 7252 | 2017-07-01 |

4. Lastly, we calculate the derived metric and return the final result set:

```bash
bookings - bookings_7_days_ago would be compile as 7438 - 7252 = 186.
```

| d7_booking_change | metric_time__month |
| ----------------- | ------------------ |
| 186 | 2017-07-01 |
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ meta:
min_supported_version: 'n/a'
slack_channel_name: '#db-bigquery'
slack_channel_link: 'https://getdbt.slack.com/archives/C99SNSRTK'
platform_name: 'Big Query'
platform_name: 'BigQuery'
config_page: '/reference/resource-configs/bigquery-configs'
---

Expand Down
1 change: 1 addition & 0 deletions website/docs/docs/trusted-adapters.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: "Trusted adapters"
id: "trusted-adapters"
hide_table_of_contents: true
---

Trusted adapters are adapters not maintained by dbt Labs, that we feel comfortable recommending to users for use in production.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ Trusted adapters will not do any of the following:
- Output to logs or file either access credentials information to or data from the underlying data platform itself.
- Make API calls other than those expressly required for using dbt features (adapters may not add additional logging)
- Obfuscate code and/or functionality so as to avoid detection
- Use the Python runtime of dbt to execute arbitrary Python code
- Draw a dependency on dbt’s Python API beyond what is required for core data transformation functionality as described in the Essential and Extended feature tiers

Additionally, to avoid supply-chain attacks:

Expand Down
Loading

0 comments on commit 4a98f84

Please sign in to comment.