Skip to content

Commit

Permalink
Add docs for start/end dates (#14)
Browse files Browse the repository at this point in the history
* Add docs for start/end dates

* Auto update table of contents

Co-authored-by: joellabes <[email protected]>
  • Loading branch information
joellabes and joellabes authored Feb 25, 2022
1 parent 604176d commit e40b0a6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* [Installation Instructions](#installation-instructions)
* [A note on refs](#warning-a-note-on-refs)
* [Usage](#usage)
* [Use cases](#use-cases)
* [Inside of dbt Models](#inside-of-dbt-models)
* [Via the interactive dbt server (coming soon)](#via-the-interactive-dbt-server-coming-soon)
* [Secondary calculations](#secondary-calculations)
Expand All @@ -20,7 +21,7 @@
* [Experimental behaviour](#-experimental-behaviour)
* [Dimensions on calendar tables](#dimensions-on-calendar-tables)

<!-- Added by: runner, at: Thu Feb 24 06:10:02 UTC 2022 -->
<!-- Added by: runner, at: Fri Feb 25 04:07:27 UTC 2022 -->

<!--te-->

Expand All @@ -34,8 +35,6 @@ Check [dbt Hub](https://hub.getdbt.com/dbt-labs/dbt_metrics/latest/) for the lat
To enable the dynamic referencing of models necessary for macro queries through the dbt Server, queries generated by this package do not participate in the DAG and `ref`'d nodes will not necessarily be built before they are accessed. Refer to the docs on [forcing dependencies](https://docs.getdbt.com/reference/dbt-jinja-functions/ref#forcing-dependencies) for more details.

# Usage

## Inside of dbt Models
Access metrics [like any other macro](https://docs.getdbt.com/docs/building-a-dbt-project/jinja-macros#using-a-macro-from-a-package):
```sql
select *
Expand All @@ -52,10 +51,17 @@ from {{ metrics.metric(

metrics.rolling(aggregate="average", interval=4, alias="avg_past_4wks"),
metrics.rolling(aggregate="min", interval=4)
]
],
start_date='2020-01-01',
end_date="date_trunc('day', getdate())"
) }}
```

`start_date` and `end_date` are optional. When not provided, the spine will span all dates from oldest to newest in the metric's dataset. This default is likely to be correct in most cases, but you can use the arguments to either narrow the resulting table or expand it (e.g. if there was no new customers until 3 January but you want to include the first two days as well). Both values are inclusive.

# Use cases

## Inside of dbt Models
You may want to materialize the results as a fixed table for querying. This is not the way we expect the dbt Metrics layer to add the most value, but is a way to experiment with the project without needing access to the interactive server.

## Via the interactive dbt server (coming soon)
Expand Down

0 comments on commit e40b0a6

Please sign in to comment.