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
Merged
38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,41 @@
# dbt_google_play_source v0.4.0
[PR #14](https://github.com/fivetran/dbt_google_play_source/pull/14) includes the following updates:

## 🚨 Breaking Changes 🚨
- Updated the source identifier format for consistency with other packages and for compatibility with the `fivetran_utils.union_data` macro. The identifier variables now are:

previous | current
--------|---------
`stats_installs_app_version_identifier` | `google_play_stats_installs_app_version_identifier`
`stats_crashes_app_version_identifier` | `google_play_stats_crashes_app_version_identifier`
`stats_ratings_app_version_identifier` | `google_play_stats_ratings_app_version_identifier`
`stats_installs_device_identifier` | `google_play_stats_installs_device_identifier`
`stats_ratings_device_identifier` | `google_play_stats_ratings_device_identifier`
`stats_installs_os_version_identifier` | `google_play_stats_installs_os_version_identifier`
`stats_ratings_os_version_identifier` | `google_play_stats_ratings_os_version_identifier`
`stats_crashes_os_version_identifier` | `google_play_stats_crashes_os_version_identifier`
`stats_installs_country_identifier` | `google_play_stats_installs_country_identifier`
`stats_ratings_country_identifier` | `google_play_stats_ratings_country_identifier`
`stats_store_performance_country_identifier` | `google_play_stats_store_performance_country_identifier`
`stats_store_performance_traffic_source_identifier` | `google_play_stats_store_performance_traffic_source_identifier`
`stats_installs_overview_identifier` | `google_play_stats_installs_overview_identifier`
`stats_crashes_overview_identifier` | `google_play_stats_crashes_overview_identifier`
`stats_ratings_overview_identifier` | `google_play_stats_ratings_overview_identifier`
`earnings_identifier` | `google_play_earnings_identifier`
`financial_stats_subscriptions_country_identifier` | `google_play_financial_stats_subscriptions_country_identifier`

- If you are using the previous identifier, be sure to update to the current version!

## Feature update 🎉
- Unioning capability! This adds the ability to union source data from multiple google_play connectors. Refer to the [README](https://github.com/fivetran/dbt_google_play_source/blob/main/README.md#union-multiple-connectors) for more details.

## Under the hood 🚘
- Added casting to staging columns that are used in any downstream COALESCEs, UNIONs, or JOINs to prevent datatype conflicts.
- Updated tmp models to union source data using the `fivetran_utils.union_data` macro.
- To distinguish which source each field comes from, added `source_relation` column in each staging model and applied the `fivetran_utils.source_relation` macro.
- Updated tests to account for the new `source_relation` column.
- Updated `src_google_play.yml` to use the current method to enable/disable sources.

# dbt_google_play_source v0.3.1
[PR #12](https://github.com/fivetran/dbt_google_play_source/pull/12) includes the following updates:
## 🪲 Bug fixes:
Expand Down
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Include the following google_play_source package version in your `packages.yml`
```yaml
packages:
- package: fivetran/google_play_source
version: [">=0.3.0", "<0.4.0"] # we recommend using ranges to capture non-breaking changes automatically
version: [">=0.4.0", "<0.5.0"] # we recommend using ranges to capture non-breaking changes automatically
```
## Step 3: Define database and schema variables
By default, this package runs using your destination and the `google_play` schema. If this is not where your google_play data is (for example, if your google_play schema is named `google_play_fivetran`), add the following configuration to your root `dbt_project.yml` file:
Expand All @@ -60,8 +60,20 @@ In order to map longform territory names to their ISO country codes, we have ada
You will need to `dbt seed` the `google_play__country_codes` [file](https://github.com/fivetran/dbt_google_play_source/blob/main/seeds/google_play__country_codes.csv) just once.

## (Optional) Step 6: Additional configurations
<details><summary>Expand to view configurations</summary>

<details open><summary>Expand/collapse configurations</summary>

### Union multiple connectors
If you have multiple google_play connectors in Fivetran and would like to use this package on all of them simultaneously, we have provided functionality to do so. The package will union all of the data together and pass the unioned table into the transformations. You will be able to see which source it came from in the `source_relation` column of each model. To use this functionality, you will need to set either the `google_play_union_schemas` OR `google_play_union_databases` variables (cannot do both) in your root `dbt_project.yml` file:

```yml
vars:
google_play_union_schemas: ['google_play_usa','google_play_canada'] # use this if the data is in different schemas/datasets of the same database/project
google_play_union_databases: ['google_play_usa','google_play_canada'] # use this if the data is in different databases/projects but uses the same schema name
```
Please be aware that the native `source.yml` connection set up in the package will not function when the union schema/database feature is utilized. Although the data will be correctly combined, you will not observe the sources linked to the package models in the Directed Acyclic Graph (DAG). This happens because the package includes only one defined `source.yml`.

To connect your multiple schema/database sources to the package models, follow the steps outlined in the [Union Data Defined Sources Configuration](https://github.com/fivetran/dbt_fivetran_utils/tree/releases/v0.4.latest#union_data-source) section of the Fivetran Utils documentation for the union_data macro. This will ensure a proper configuration and correct visualization of connections in the DAG.

### Change the build schema
By default, this package builds the google_play staging models within a schema titled (`<target_schema>` + `_google_play_source`) in your destination. If this is not where you would like your google_play staging data to be written to, add the following configuration to your root `dbt_project.yml` file:

Expand All @@ -77,7 +89,7 @@ If an individual source table has a different name than the package expects, add

```yml
vars:
<default_source_table_name>_identifier: your_table_name
google_play_<default_source_table_name>_identifier: your_table_name
```

</details>
Expand Down
24 changes: 12 additions & 12 deletions dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
name: 'google_play_source'
version: '0.3.1'
version: '0.4.0'
config-version: 2
require-dbt-version: [">=1.3.0", "<2.0.0"]
vars:
google_play_source:
stats_installs_app_version: "{{ source('google_play', 'stats_installs_app_version') }}"
earnings: "{{ source('google_play', 'earnings') }}"
financial_stats_subscriptions_country: "{{ source('google_play', 'financial_stats_subscriptions_country') }}"
stats_crashes_app_version: "{{ source('google_play', 'stats_crashes_app_version') }}"
stats_ratings_app_version: "{{ source('google_play', 'stats_ratings_app_version') }}"
stats_installs_device: "{{ source('google_play', 'stats_installs_device') }}"
stats_ratings_device: "{{ source('google_play', 'stats_ratings_device') }}"
stats_installs_os_version: "{{ source('google_play', 'stats_installs_os_version') }}"
stats_ratings_os_version: "{{ source('google_play', 'stats_ratings_os_version') }}"
stats_crashes_os_version: "{{ source('google_play', 'stats_crashes_os_version') }}"
stats_crashes_overview: "{{ source('google_play', 'stats_crashes_overview') }}"
stats_installs_app_version: "{{ source('google_play', 'stats_installs_app_version') }}"
stats_installs_country: "{{ source('google_play', 'stats_installs_country') }}"
stats_installs_device: "{{ source('google_play', 'stats_installs_device') }}"
stats_installs_os_version: "{{ source('google_play', 'stats_installs_os_version') }}"
stats_installs_overview: "{{ source('google_play', 'stats_installs_overview') }}"
stats_ratings_app_version: "{{ source('google_play', 'stats_ratings_app_version') }}"
stats_ratings_country: "{{ source('google_play', 'stats_ratings_country') }}"
stats_ratings_device: "{{ source('google_play', 'stats_ratings_device') }}"
stats_ratings_os_version: "{{ source('google_play', 'stats_ratings_os_version') }}"
stats_ratings_overview: "{{ source('google_play', 'stats_ratings_overview') }}"
stats_store_performance_country: "{{ source('google_play', 'stats_store_performance_country') }}"
stats_store_performance_traffic_source: "{{ source('google_play', 'stats_store_performance_traffic_source') }}"
stats_installs_overview: "{{ source('google_play', 'stats_installs_overview') }}"
stats_crashes_overview: "{{ source('google_play', 'stats_crashes_overview') }}"
stats_ratings_overview: "{{ source('google_play', 'stats_ratings_overview') }}"
earnings: "{{ source('google_play', 'earnings') }}"
financial_stats_subscriptions_country: "{{ source('google_play', 'financial_stats_subscriptions_country') }}"
models:
google_play_source:
+schema: google_play_source
Expand Down
2 changes: 1 addition & 1 deletion docs/catalog.json

Large diffs are not rendered by default.

Loading