Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/postgres performance updates #26

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
target/
dbt_packages/
logs/
package-lock.yml
package-lock.yml
env/
.DS_Store
2 changes: 2 additions & 0 deletions dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ models:
+schema: apple_store
intermediate:
+materialized: ephemeral
reporting_grain:
+materialized: table
2 changes: 1 addition & 1 deletion integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version: '0.4.0'
profile: 'integration_tests'

vars:
# apple_store__using_subscriptions: True # un-comment this line when generating docs!
apple_store__using_subscriptions: True # un-comment this line when generating docs!
apple_store_schema: apple_store_integration_tests_7
apple_store_source:
apple_store_app_identifier: "app"
Expand Down
24 changes: 2 additions & 22 deletions models/apple_store__app_version_report.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,10 @@ usage_app_version_report as (
from {{ var('usage_app_version') }}
),

reporting_grain_combined as (

select
source_relation,
date_day,
app_id,
source_type,
app_version
from usage_app_version_report
union all
select
source_relation,
date_day,
app_id,
source_type,
app_version
from crashes_app_version_report
),

reporting_grain as (

select
distinct *
from reporting_grain_combined
select *
from {{ ref('int_apple_store__usage_crash_report') }}
),

joined as (
Expand Down
24 changes: 2 additions & 22 deletions models/apple_store__device_report.sql
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,10 @@ subscription_device as (
),
{% endif %}

reporting_grain_combined as (

select
source_relation,
date_day,
app_id,
source_type,
device
from app_store_device
union all
select
source_relation,
date_day,
app_id,
source_type,
device
from crashes_device
),

reporting_grain as (

select
distinct *
from reporting_grain_combined
select *
from {{ ref('int_apple_store__device_crash_report') }}
),

joined as (
Expand Down
7 changes: 2 additions & 5 deletions models/apple_store__overview_report.sql
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,8 @@ usage as (

reporting_grain as (

select distinct
source_relation,
date_day,
app_id
from app_store
select *
from {{ ref('int_apple_store__app_store_report') }}
),

joined as (
Expand Down
25 changes: 2 additions & 23 deletions models/apple_store__platform_version_report.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,10 @@ usage_platform_version as (
from {{ var('usage_platform_version') }}
),

reporting_grain_combined as (

select
source_relation,
date_day,
app_id,
source_type,
platform_version
from app_store_platform_version
union all
select
source_relation,
date_day,
app_id,
source_type,
platform_version
from crashes_platform_version
),

reporting_grain as (

select
distinct *
from reporting_grain_combined

select *
from {{ ref('int_apple_store__platform_crash_report') }}
),

joined as (
Expand Down
8 changes: 2 additions & 6 deletions models/apple_store__source_type_report.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@ usage_source_type as (

reporting_grain as (

select distinct
source_relation,
date_day,
app_id,
source_type
from app_store_source_type
select *
from {{ ref('int_apple_store__source_type_report') }}
),

joined as (
Expand Down
32 changes: 2 additions & 30 deletions models/apple_store__subscription_report.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,10 @@ country_codes as (
from {{ var('apple_store_country_codes') }}
),

reporting_grain_combined as (

select
source_relation,
cast(date_day as date) as date_day,
account_id,
account_name,
app_name,
app_id,
subscription_name,
country,
state
from subscription_summary
union all
select
source_relation,
cast(date_day as date) as date_day,
account_id,
account_name,
app_name,
app_id,
subscription_name,
country,
state
from subscription_events
),

reporting_grain as (

select
distinct *
from reporting_grain_combined
select *
from {{ ref('int_apple_store__subscription_report') }}
),

joined as (
Expand Down
9 changes: 2 additions & 7 deletions models/apple_store__territory_report.sql
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,8 @@ usage_territory as (

reporting_grain as (

select distinct
source_relation,
date_day,
app_id,
source_type,
territory
from app_store_territory
select *
from {{ ref('int_apple_store__territory_report_grain') }}
),

joined as (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
with app_store as (

select *
from {{ ref('int_apple_store__app_store_overview') }}
),

final as (

select distinct
source_relation,
date_day,
app_id
from app_store
)

select *
from final
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
with app_store_device as (

select *
from {{ var('app_store_device') }}
),

crashes_device as (

select *
from {{ ref('int_apple_store__crashes_device') }}
),

reporting_grain_combined as (

select
source_relation,
date_day,
app_id,
source_type,
device
from app_store_device
union all
select
source_relation,
date_day,
app_id,
source_type,
device
from crashes_device
),

final as (

select distinct *
from reporting_grain_combined
)

select *
from final
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
with app_store_platform_version as (

select *
from {{ var('app_store_platform_version') }}
),

crashes_platform_version as (

select *
from {{ ref('int_apple_store__platform_version') }}
),

reporting_grain_combined as (

select
source_relation,
date_day,
app_id,
source_type,
platform_version
from app_store_platform_version
union all
select
source_relation,
date_day,
app_id,
source_type,
platform_version
from crashes_platform_version
),

final as (

select distinct *
from reporting_grain_combined
)

select *
from final
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
with app_store_source_type as (

select *
from {{ ref('int_apple_store__app_store_source_type') }}
),

final as (

select distinct
source_relation,
date_day,
app_id,
source_type
from app_store_source_type
)

select *
from final
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{{ config(enabled=var('apple_store__using_subscriptions', False)) }}

with subscription_summary as (

select *
from {{ ref('int_apple_store__sales_subscription_summary') }}
),

subscription_events as (

select *
from {{ ref('int_apple_store__sales_subscription_events') }}
),

reporting_grain_combined as (

select
source_relation,
cast(date_day as date) as date_day,
account_id,
account_name,
app_name,
app_id,
subscription_name,
country,
state
from subscription_summary
union all
select
source_relation,
cast(date_day as date) as date_day,
account_id,
account_name,
app_name,
app_id,
subscription_name,
country,
state
from subscription_events
),

final as (

select distinct *
from reporting_grain_combined
)

select *
from final
Loading