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

Feature: Union schema compatibility #14

Merged
merged 11 commits into from
Jul 23, 2024
Prev Previous commit
Next Next commit
update test
fivetran-catfritz committed Jul 22, 2024
commit 3a12082baaaf86d6c8483ac1aad64a857d5e4149
10 changes: 4 additions & 6 deletions models/stg_google_play.yml
Original file line number Diff line number Diff line change
@@ -337,16 +337,14 @@ models:

- name: stg_google_play__store_performance_source
description: Each line is a daily snapshot of the monthly store performance report by app and type of traffic source.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- source_relation
- traffic_source_unique_key
columns:
- name: source_relation
description: "{{ doc('source_relation') }}"
- name: traffic_source_unique_key
description: Surrogate key hashed on `date_day`, `package_name`, `traffic_source`, `search_term`, `utm_campaign`, and `utm_source`.
description: Surrogate key hashed on `source_relation`, `date_day`, `package_name`, `traffic_source`, `search_term`, `utm_campaign`, and `utm_source`.
tests:
- unique
- not null
- name: date_day
description: '{{ doc("date") }}'
- name: package_name
2 changes: 1 addition & 1 deletion models/stg_google_play__stats_crashes_app_version.sql
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ final as (
select
cast(source_relation as {{ dbt.type_string() }}) as source_relation,
cast(date as date) as date_day,
cast(app_version_code as {{ dbt.type_string() }}) as app_version_code,
cast(app_version_code as {{ dbt.type_int() }}) as app_version_code,
cast(package_name as {{ dbt.type_string() }}) as package_name,
sum(cast(daily_anrs as {{ dbt.type_bigint() }})) as anrs,
sum(cast(daily_crashes as {{ dbt.type_bigint() }})) as crashes
2 changes: 1 addition & 1 deletion models/stg_google_play__stats_installs_app_version.sql
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ final as (
select
cast(source_relation as {{ dbt.type_string() }}) as source_relation,
cast(date as date) as date_day,
cast(app_version_code as {{ dbt.type_string() }}) as app_version_code,
cast(app_version_code as {{ dbt.type_int() }}) as app_version_code,
cast(package_name as {{ dbt.type_string() }}) as package_name,
sum(cast(active_device_installs as {{ dbt.type_bigint() }})) as active_devices_last_30_days,
sum(cast(daily_device_installs as {{ dbt.type_bigint() }})) as device_installs,
2 changes: 1 addition & 1 deletion models/stg_google_play__stats_ratings_app_version.sql
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ final as (
select
cast(source_relation as {{ dbt.type_string() }}) as source_relation,
cast(date as date) as date_day,
cast(app_version_code as {{ dbt.type_string() }}) as app_version_code,
cast(app_version_code as {{ dbt.type_int() }}) as app_version_code,
cast(package_name as {{ dbt.type_string() }}) as package_name,
case when app_version_code is null then null else cast( nullif(cast(daily_average_rating as {{ dbt.type_string() }}), 'NA') as {{ dbt.type_float() }} ) end as average_rating,
case when app_version_code is null then null else total_average_rating end as rolling_total_average_rating
2 changes: 1 addition & 1 deletion models/stg_google_play__store_performance_source.sql
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ final as (
store_listing_conversion_rate,
cast(store_listing_visitors as {{ dbt.type_bigint() }}) as store_listing_visitors,
-- make a surrogate key as the PK involves quite a few columns
{{ dbt_utils.generate_surrogate_key(['date', 'package_name', 'traffic_source', 'search_term', 'utm_campaign', 'utm_source']) }} as traffic_source_unique_key,
{{ dbt_utils.generate_surrogate_key(['source_relation', 'date', 'package_name', 'traffic_source', 'search_term', 'utm_campaign', 'utm_source']) }} as traffic_source_unique_key,
_fivetran_synced
from fields
)