-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 558c193
Showing
9 changed files
with
137 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.DS_Store | ||
target/ | ||
dbt_modules/ | ||
logs/ |
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,15 @@ | ||
Welcome to your new dbt project! | ||
|
||
### Using the starter project | ||
|
||
Try running the following commands: | ||
- dbt run | ||
- dbt test | ||
|
||
|
||
### Resources: | ||
- Learn more about dbt [in the docs](https://docs.getdbt.com/docs/introduction) | ||
- Check out [Discourse](https://discourse.getdbt.com/) for commonly asked questions and answers | ||
- Join the [chat](http://slack.getdbt.com/) on Slack for live discussions and support | ||
- Find [dbt events](https://events.getdbt.com) near you | ||
- Check out [the blog](https://blog.getdbt.com/) for the latest news on dbt's development and best practices |
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,14 @@ | ||
name: 'marketo' | ||
version: '1.0.0' | ||
|
||
source-paths: ["models"] | ||
analysis-paths: ["analysis"] | ||
test-paths: ["tests"] | ||
data-paths: ["data"] | ||
macro-paths: ["macros"] | ||
snapshot-paths: ["snapshots"] | ||
|
||
target-path: "target" # directory which will store compiled SQL files | ||
clean-targets: # directories to be removed by `dbt clean` | ||
- "target" | ||
- "dbt_modules" |
Empty file.
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,22 @@ | ||
with base as ( | ||
|
||
select * | ||
from {{ var('activity_change_data_value') }} | ||
where lead_id = 29616 | ||
|
||
), fields as ( | ||
|
||
select | ||
id, | ||
activity_date, | ||
lead_id, | ||
new_value, | ||
old_value, | ||
primary_attribute_value, | ||
primary_attribute_value_id | ||
from base | ||
|
||
) | ||
|
||
select * | ||
from fields |
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 @@ | ||
with base as ( | ||
|
||
select * | ||
from {{ var('lead_describe') }} | ||
|
||
), fields as ( | ||
|
||
select | ||
id, | ||
restname | ||
from base | ||
|
||
) | ||
|
||
select * | ||
from fields |
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,63 @@ | ||
{% set results = run_query('select restname from ' ~ ref('stg_lead_describe')) %} | ||
|
||
{% if execute %} | ||
{# Return the first column #} | ||
{% set results_list = results.columns[0].values() %} | ||
{% else %} | ||
{% set results_list = [] %} | ||
{% endif %} | ||
|
||
with change_data as ( | ||
|
||
select * | ||
from {{ ref('stg_activity_change_data_value') }} | ||
|
||
), lead_describe as ( | ||
|
||
select * | ||
from {{ ref('stg_lead_describe') }} | ||
|
||
), joined as ( | ||
|
||
select | ||
change_data.*, | ||
lead_describe.restname as primary_attribute_column | ||
from change_data | ||
left join lead_describe | ||
on change_data.primary_attribute_value_id = lead_describe.id | ||
|
||
), event_order as ( | ||
|
||
select | ||
*, | ||
row_number() over ( | ||
partition by cast(activity_date as date), lead_id, primary_attribute_value_id | ||
order by activity_date asc | ||
) as row_num | ||
from joined | ||
|
||
), filtered as ( | ||
|
||
select * | ||
from event_order | ||
where row_num = 1 | ||
|
||
), pivot as ( | ||
|
||
select | ||
cast(activity_date as date) as date_day, | ||
lead_id, | ||
|
||
{% for col in results_list %} | ||
{% set col_xf = col|lower|replace("__c","_c") %} | ||
min(case when lower(primary_attribute_column) = '{{ col_xf }}' then new_value end) as {{ col_xf }} | ||
{% if not loop.last %} , {% endif %} | ||
{% endfor %} | ||
|
||
from filtered | ||
group by 1,2 | ||
|
||
) | ||
|
||
select * | ||
from pivot |
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,3 @@ | ||
packages: | ||
- package: fishtown-analytics/dbt_utils | ||
version: 0.3.0 |
Empty file.