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 21 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 18 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
2 changes: 1 addition & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ steps:
commands: |
bash .buildkite/scripts/run_models.sh redshift
- label: ":bricks: Run Tests - Databricks"
- label: ":databricks: Run Tests - Databricks"
key: "run_dbt_databricks"
plugins:
- docker#v3.13.0:
Expand Down
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
# dbt_apple_store_source v0.4.0
[PR #14](https://github.com/fivetran/dbt_apple_store_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
--------|---------
`app_identifier` | `apple_store_app_identifier`
`app_store_platform_version_source_type_report_identifier` | `apple_store_app_store_platform_version_source_type_report_identifier`
`app_store_source_type_device_report_identifier` | `apple_store_app_store_source_type_device_report_identifier`
`app_store_territory_source_type_report_identifier` | `apple_store_app_store_territory_source_type_report_identifier`
`crashes_app_version_device_report_identifier` | `apple_store_crashes_app_version_device_report_identifier`
`crashes_platform_version_device_report_identifier` | `apple_store_crashes_platform_version_device_report_identifier`
`downloads_platform_version_source_type_report_identifier` | `apple_store_downloads_platform_version_source_type_report_identifier`
`downloads_source_type_device_report_identifier` | `apple_store_downloads_source_type_device_report_identifier`
`downloads_territory_source_type_report_identifier` | `apple_store_downloads_territory_source_type_report_identifier`
`sales_account_identifier` | `apple_store_sales_account_identifier`
`sales_subscription_event_summary_identifier` | `apple_store_sales_subscription_event_summary_identifier`
`sales_subscription_summary_identifier` | `apple_store_sales_subscription_summary_identifier`
`usage_app_version_source_type_report_identifier` | `apple_store_usage_app_version_source_type_report_identifier`
`usage_platform_version_source_type_report_identifier` | `apple_store_usage_platform_version_source_type_report_identifier`
`usage_source_type_device_report_identifier` | `apple_store_usage_source_type_device_report_identifier`
`usage_territory_source_type_report_identifier` | `apple_store_usage_territory_source_type_report_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 apple_store connectors. Refer to the [README](https://github.com/fivetran/dbt_apple_store_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.
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved
- 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.
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved
- Updated tests to account for the new `source_relation` column.
- Updated `src_apple_store.yml` to use the current method to enable/disable sources.

# dbt_apple_store_source v0.3.1

## Bug Fix
Expand Down
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Include the following apple_store_source package version in your `packages.yml`
```yaml
packages:
- package: fivetran/apple_store_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 `apple_store` schema. If this is not where your apple_store data is (for example, if your apple_store schema is named `apple_store_fivetran`), add the following configuration to your root `dbt_project.yml` file:
Expand All @@ -56,7 +56,19 @@ In order to map longform territory names to their ISO country codes, we have ada
You will need to `dbt seed` the `apple_store_country_codes` [file](https://github.com/fivetran/dbt_apple_store_source/blob/main/seeds/apple_store_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 apple_store 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 `apple_store_union_schemas` OR `apple_store_union_databases` variables (cannot do both) in your root `dbt_project.yml` file:

```yml
vars:
apple_store_union_schemas: ['apple_store_usa','apple_store_canada'] # use this if the data is in different schemas/datasets of the same database/project
apple_store_union_databases: ['apple_store_usa','apple_store_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.

### Defining subscription events
By default, `Subscribe`, `Renew` and `Cancel` subscription events are included and required in this package for downstream usage. If you would like to add additional subscription events, please add the below to your `dbt_project.yml`:
Expand Down Expand Up @@ -85,7 +97,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
apple_store_<default_source_table_name>_identifier: your_table_name
```

</details>
Expand Down
18 changes: 9 additions & 9 deletions dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
name: 'apple_store_source'
version: '0.3.2'
version: '0.4.0'
config-version: 2
require-dbt-version: [">=1.3.0", "<2.0.0"]
vars:
apple_store_source:
app: "{{ source('apple_store', 'app') }}"
app_store_device: "{{ source('apple_store', 'app_store_source_type_device_report') }}"
usage_device: "{{ source('apple_store', 'usage_source_type_device_report') }}"
downloads_device: "{{ source('apple_store', 'downloads_source_type_device_report') }}"
app_store_territory: "{{ source('apple_store', 'app_store_territory_source_type_report') }}"
downloads_territory: "{{ source('apple_store', 'downloads_territory_source_type_report') }}"
usage_territory: "{{ source('apple_store', 'usage_territory_source_type_report') }}"
app_store_platform_version: "{{ source('apple_store', 'app_store_platform_version_source_type_report') }}"
app_store_territory: "{{ source('apple_store', 'app_store_territory_source_type_report') }}"
crashes_app_version: "{{ source('apple_store', 'crashes_app_version_device_report') }}"
crashes_platform_version: "{{ source('apple_store', 'crashes_platform_version_device_report') }}"
downloads_device: "{{ source('apple_store', 'downloads_source_type_device_report') }}"
downloads_platform_version: "{{ source('apple_store', 'downloads_platform_version_source_type_report') }}"
usage_platform_version: "{{ source('apple_store', 'usage_platform_version_source_type_report') }}"
crashes_app_version: "{{ source('apple_store', 'crashes_app_version_device_report') }}"
usage_app_version: "{{ source('apple_store', 'usage_app_version_source_type_report') }}"
downloads_territory: "{{ source('apple_store', 'downloads_territory_source_type_report') }}"
sales_account: "{{ source('apple_store', 'sales_account') }}"
sales_subscription_events: "{{ source('apple_store', 'sales_subscription_event_summary') }}"
sales_subscription_summary: "{{ source('apple_store', 'sales_subscription_summary') }}"
usage_app_version: "{{ source('apple_store', 'usage_app_version_source_type_report') }}"
usage_device: "{{ source('apple_store', 'usage_source_type_device_report') }}"
usage_platform_version: "{{ source('apple_store', 'usage_platform_version_source_type_report') }}"
usage_territory: "{{ source('apple_store', 'usage_territory_source_type_report') }}"
apple_store_country_codes: "{{ ref('apple_store_country_codes') }}"
apple_store__subscription_events:
- 'Renew'
Expand Down
2 changes: 1 addition & 1 deletion docs/catalog.json

Large diffs are not rendered by default.

Loading