-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from bcodell/bryce/timespine-poc
Feature: Time Spine Datasets
- Loading branch information
Showing
12 changed files
with
285 additions
and
35 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
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
16 changes: 16 additions & 0 deletions
16
integration_tests/models/datasets/time_spine/dataset__time_spine.sql
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{% set aql %} | ||
using customer_stream | ||
select time_spine(interval=month, end_period=max) visited_page ( | ||
entity_uuid as customer_id | ||
) | ||
aggregate between bought_something( | ||
sum(total_items_purchased) as total_items_purchased_between, | ||
sum(total_sales) as total_sales_between, | ||
count(activity_id) as total_purchases_between | ||
) | ||
{% endset %} | ||
|
||
-- depends_on: {{ ref('output__time_spine') }} | ||
|
||
{{ dbt_activity_schema.dataset(aql) }} | ||
order by 3,1 |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
version: 2 | ||
|
||
models: | ||
|
||
- name: dataset__time_spine | ||
description: A test to validate the functionality of macro-based dataset generation. | ||
tests: | ||
- dbt_utils.equality: | ||
compare_model: ref("output__time_spine") |
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
13 changes: 13 additions & 0 deletions
13
integration_tests/seeds/datasets/time_spine/output__time_spine.csv
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
ts,activity_id,customer_id,total_items_purchased_between,total_sales_between,total_purchases_between | ||
2022-01-01,ac78479a9f4e0a82141e63285e0bd937,1,6,350,2 | ||
2022-02-01,40baeaad6b5e05afb0f2346f3f73f2c4,1,5,250,1 | ||
2022-03-01,c258c810fde59ef5e4d5f0c5b3b59c50,1,0,0,0 | ||
2022-01-01,d242adbbac9ebdbba8caf4d669a13db8,4,2,80,1 | ||
2022-02-01,b040c6925c8a8b4fda30d87bb3c828fe,4,6,600,2 | ||
2022-03-01,414fd7624da769643b82b680a0476d01,4,0,0,0 | ||
2022-01-01,e93fa0bce5965387e1ee99086d13ebba,7,3,120,1 | ||
2022-02-01,6b62dceb80db68b6260c1ab313a13d36,7,2,150,2 | ||
2022-03-01,e554eceabffb4739dffa03e6d96d90b0,7,0,0,0 | ||
2022-01-01,5168a14e1555818beb23a394f9e2f95f,10,4,50,1 | ||
2022-02-01,91ee7a6ca7f704b424afae0af772078c,10,18,1600,2 | ||
2022-03-01,97e03bb3fa450367f3fff74634a2f886,10,0,0,0 |
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
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
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
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{% macro dateadd(interval, periods, ts) %} | ||
{{ return(adapter.dispatch('dateadd', 'dbt_activity_schema')(interval, periods, ts)) }} | ||
{% endmacro %} | ||
|
||
{% macro default__dateadd(interval, periods, ts) %} | ||
dateadd({{interval}}, {{periods}}, {{ts}}) | ||
{% endmacro %} | ||
|
||
{% macro duckdb__dateadd(interval, periods, ts) %} | ||
date_add({{ts}}, {{periods}} * interval 1 {{interval}}) | ||
{% endmacro %} | ||
|
||
{% macro snowflake__dateadd(interval, periods, ts) %} | ||
dateadd({{interval}}, {{periods}}, {{ts}}) | ||
{% endmacro %} | ||
|
||
{% macro redshift__dateadd(interval, periods, ts) %} | ||
dateadd({{interval}}, {{periods}}, {{ts}}) | ||
{% endmacro %} | ||
|
||
{% macro bigquery__dateadd(interval, periods, ts) %} | ||
date_add({{ts}}, {{periods}} * interval 1 {{interval}}) | ||
{% endmacro %} | ||
|
||
|
||
|
||
SELECT DATE_ADD(DATE('2025-01-01'), INTERVAL 7 DAY) AS new_date; |
Oops, something went wrong.