Skip to content

Commit

Permalink
Merge pull request #5 from fishtown-analytics/feature/add-package-man…
Browse files Browse the repository at this point in the history
…ager

Feature: add package manager
  • Loading branch information
jthandy authored Jan 4, 2019
2 parents 9304fd6 + f78a569 commit 500f477
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 162 deletions.
23 changes: 0 additions & 23 deletions macros/concat.sql

This file was deleted.

61 changes: 5 additions & 56 deletions macros/cross-adapter-modeling/base/segment_web_page_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,79 +22,28 @@ renamed as (
user_id,

received_at as received_at_tstamp,
sent_at as sent_at_tstamp,
sent_at as sent_at_tstamp,
timestamp as tstamp,

url as page_url,
split_part(split_part(split_part(url, '//', 2),'/', 1),'?',1)::varchar
as page_url_host,
{{ dbt_utils.get_url_host('url') }} as page_url_host,
path as page_url_path,
title as page_title,
search as page_url_query,

referrer,
ltrim(split_part(split_part(referrer, '.com', 1), '//',2),'www.')::varchar
ltrim({{ dbt_utils.get_url_host('referrer') }}, 'www.')::varchar
as referrer_host,

context_campaign_source as utm_source,
context_campaign_medium as utm_medium,
context_campaign_name as utm_campaign,
context_campaign_term as utm_term,
context_campaign_content as utm_content,
nullif(split_part(split_part(url, 'gclid=', 2),'&', 1)::varchar,'')
as gclid,

context_ip as ip,
{{ dbt_utils.get_url_parameter('url', 'gclid') }} as gclid,
context_ip as ip,
context_user_agent as user_agent

from source

)

select * from renamed

{% endmacro %}


{% macro snowflake__segment_web_page_views() %}

with source as (

select * from {{var('segment_page_views_table')}}

),

renamed as (

select

id as page_view_id,
anonymous_id,
user_id,

received_at as received_at_tstamp,
sent_at as sent_at_tstamp,
timestamp as tstamp,

url as page_url,
parse_url(url)['host']::varchar as page_url_host,
path as page_url_path,
title as page_title,
search as page_url_query,

referrer,
parse_url(referrer)['host']::varchar as referrer_host,

context_campaign_source as utm_source,
context_campaign_medium as utm_medium,
context_campaign_name as utm_campaign,
context_campaign_term as utm_term,
context_campaign_content as utm_content,
nullif(parse_url(url)['parameters']['gclid']::varchar, '') as gclid,

context_ip as ip,
context_user_agent as user_agent

from source

)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ session_ids as (

select

{{segment.star(ref('segment_web_page_views'))}},
{{dbt_utils.star(ref('segment_web_page_views'))}},
page_view_number,
{{segment.surrogate_key('anonymous_id', 'session_number')}} as session_id
{{dbt_utils.surrogate_key('anonymous_id', 'session_number')}} as session_id

from session_numbers

Expand Down
13 changes: 0 additions & 13 deletions macros/hash.sql

This file was deleted.

30 changes: 0 additions & 30 deletions macros/star.sql

This file was deleted.

19 changes: 0 additions & 19 deletions macros/surrogate_key.sql

This file was deleted.

19 changes: 0 additions & 19 deletions macros/type_string.sql

This file was deleted.

3 changes: 3 additions & 0 deletions packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
packages:
- package: fishtown-analytics/dbt-utils
version: '>=0.1.20'

0 comments on commit 500f477

Please sign in to comment.