Skip to content

Commit e40b0a6

Browse files
authored
Add docs for start/end dates (#14)
* Add docs for start/end dates * Auto update table of contents Co-authored-by: joellabes <joellabes@users.noreply.github.com>
1 parent 604176d commit e40b0a6

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* [Installation Instructions](#installation-instructions)
77
* [A note on refs](#warning-a-note-on-refs)
88
* [Usage](#usage)
9+
* [Use cases](#use-cases)
910
* [Inside of dbt Models](#inside-of-dbt-models)
1011
* [Via the interactive dbt server (coming soon)](#via-the-interactive-dbt-server-coming-soon)
1112
* [Secondary calculations](#secondary-calculations)
@@ -20,7 +21,7 @@
2021
* [Experimental behaviour](#-experimental-behaviour)
2122
* [Dimensions on calendar tables](#dimensions-on-calendar-tables)
2223

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

2526
<!--te-->
2627

@@ -34,8 +35,6 @@ Check [dbt Hub](https://hub.getdbt.com/dbt-labs/dbt_metrics/latest/) for the lat
3435
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.
3536

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

5352
metrics.rolling(aggregate="average", interval=4, alias="avg_past_4wks"),
5453
metrics.rolling(aggregate="min", interval=4)
55-
]
54+
],
55+
start_date='2020-01-01',
56+
end_date="date_trunc('day', getdate())"
5657
) }}
5758
```
5859

60+
`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.
61+
62+
# Use cases
63+
64+
## Inside of dbt Models
5965
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.
6066

6167
## Via the interactive dbt server (coming soon)

0 commit comments

Comments
 (0)