Skip to content

Commit fce24ad

Browse files
Feature: Union schema compatibility (#14)
* MagicBot/add-union-schema updates * revisions from automated results * update groups * update identifiers * update for buildkite * update casts * cast ids * cast strings * fix typos * update readme & changelog * update config & move docs * update cast * update changelog and add autoreleaser * regen docs
1 parent 08045a2 commit fce24ad

File tree

46 files changed

+647
-301
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+647
-301
lines changed

.buildkite/pipeline.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ steps:
5858
commands: |
5959
bash .buildkite/scripts/run_models.sh redshift
6060
61-
- label: ":bricks: Run Tests - Databricks"
61+
- label: ":databricks: Run Tests - Databricks"
6262
key: "run_dbt_databricks"
6363
plugins:
6464
- docker#v3.13.0:

.github/workflows/auto-release.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: 'auto release'
2+
on:
3+
pull_request:
4+
types:
5+
- closed
6+
branches:
7+
- main
8+
9+
jobs:
10+
call-workflow-passing-data:
11+
if: github.event.pull_request.merged
12+
uses: fivetran/dbt_package_automations/.github/workflows/auto-release.yml@main
13+
secrets: inherit

CHANGELOG.md

+40
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,43 @@
1+
# dbt_apple_store_source v0.4.0
2+
[PR #14](https://github.com/fivetran/dbt_apple_store_source/pull/14) includes the following updates:
3+
4+
## 🚨 Breaking Changes 🚨
5+
- 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:
6+
7+
previous | current
8+
--------|---------
9+
`app_identifier` | `apple_store_app_identifier`
10+
`app_store_platform_version_source_type_report_identifier` | `apple_store_app_store_platform_version_source_type_report_identifier`
11+
`app_store_source_type_device_report_identifier` | `apple_store_app_store_source_type_device_report_identifier`
12+
`app_store_territory_source_type_report_identifier` | `apple_store_app_store_territory_source_type_report_identifier`
13+
`crashes_app_version_device_report_identifier` | `apple_store_crashes_app_version_device_report_identifier`
14+
`crashes_platform_version_device_report_identifier` | `apple_store_crashes_platform_version_device_report_identifier`
15+
`downloads_platform_version_source_type_report_identifier` | `apple_store_downloads_platform_version_source_type_report_identifier`
16+
`downloads_source_type_device_report_identifier` | `apple_store_downloads_source_type_device_report_identifier`
17+
`downloads_territory_source_type_report_identifier` | `apple_store_downloads_territory_source_type_report_identifier`
18+
`sales_account_identifier` | `apple_store_sales_account_identifier`
19+
`sales_subscription_event_summary_identifier` | `apple_store_sales_subscription_event_summary_identifier`
20+
`sales_subscription_summary_identifier` | `apple_store_sales_subscription_summary_identifier`
21+
`usage_app_version_source_type_report_identifier` | `apple_store_usage_app_version_source_type_report_identifier`
22+
`usage_platform_version_source_type_report_identifier` | `apple_store_usage_platform_version_source_type_report_identifier`
23+
`usage_source_type_device_report_identifier` | `apple_store_usage_source_type_device_report_identifier`
24+
`usage_territory_source_type_report_identifier` | `apple_store_usage_territory_source_type_report_identifier`
25+
26+
- If you are using the previous identifier, be sure to update to the current version!
27+
28+
## Feature update 🎉
29+
- 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.
30+
- Added a `source_relation` column in each staging model for tracking the source of each record.
31+
- Updated tests to account for the new `source_relation` column.
32+
- Added casting to staging columns that are used in any downstream COALESCEs, UNIONs, or JOINs to prevent datatype conflicts.
33+
- Metric fields, such as `crashes`, `impressions`, `page_views`, etc., are now cast as the datatype determined by the `dbt.type_bigint()` macro for your warehouse.
34+
35+
## Under the hood 🚘
36+
- Updated tmp models to union source data using the `fivetran_utils.union_data` macro.
37+
- Applied the `fivetran_utils.source_relation` macro in each staging model to determine the `source_relation`.
38+
- Updated `src_apple_store.yml` to use the current method to enable/disable sources.
39+
- Included auto-releaser GitHub Actions workflow to automate future releases.
40+
141
# dbt_apple_store_source v0.3.1
242

343
## Bug Fix

README.md

+15-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Include the following apple_store_source package version in your `packages.yml`
3131
```yaml
3232
packages:
3333
- package: fivetran/apple_store_source
34-
version: [">=0.3.0", "<0.4.0"] # we recommend using ranges to capture non-breaking changes automatically
34+
version: [">=0.4.0", "<0.5.0"] # we recommend using ranges to capture non-breaking changes automatically
3535
```
3636
## Step 3: Define database and schema variables
3737
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:
@@ -56,7 +56,19 @@ In order to map longform territory names to their ISO country codes, we have ada
5656
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.
5757

5858
## (Optional) Step 6: Additional configurations
59-
<details><summary>Expand to view configurations</summary>
59+
<details open><summary>Expand/collapse configurations</summary>
60+
61+
### Union multiple connectors
62+
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:
63+
64+
```yml
65+
vars:
66+
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
67+
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
68+
```
69+
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`.
70+
71+
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.
6072

6173
### Defining subscription events
6274
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`:
@@ -85,7 +97,7 @@ If an individual source table has a different name than the package expects, add
8597

8698
```yml
8799
vars:
88-
<default_source_table_name>_identifier: your_table_name
100+
apple_store_<default_source_table_name>_identifier: your_table_name
89101
```
90102

91103
</details>

dbt_project.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
name: 'apple_store_source'
2-
version: '0.3.2'
2+
version: '0.4.0'
33
config-version: 2
44
require-dbt-version: [">=1.3.0", "<2.0.0"]
55
vars:
66
apple_store_source:
77
app: "{{ source('apple_store', 'app') }}"
88
app_store_device: "{{ source('apple_store', 'app_store_source_type_device_report') }}"
9-
usage_device: "{{ source('apple_store', 'usage_source_type_device_report') }}"
10-
downloads_device: "{{ source('apple_store', 'downloads_source_type_device_report') }}"
11-
app_store_territory: "{{ source('apple_store', 'app_store_territory_source_type_report') }}"
12-
downloads_territory: "{{ source('apple_store', 'downloads_territory_source_type_report') }}"
13-
usage_territory: "{{ source('apple_store', 'usage_territory_source_type_report') }}"
149
app_store_platform_version: "{{ source('apple_store', 'app_store_platform_version_source_type_report') }}"
10+
app_store_territory: "{{ source('apple_store', 'app_store_territory_source_type_report') }}"
11+
crashes_app_version: "{{ source('apple_store', 'crashes_app_version_device_report') }}"
1512
crashes_platform_version: "{{ source('apple_store', 'crashes_platform_version_device_report') }}"
13+
downloads_device: "{{ source('apple_store', 'downloads_source_type_device_report') }}"
1614
downloads_platform_version: "{{ source('apple_store', 'downloads_platform_version_source_type_report') }}"
17-
usage_platform_version: "{{ source('apple_store', 'usage_platform_version_source_type_report') }}"
18-
crashes_app_version: "{{ source('apple_store', 'crashes_app_version_device_report') }}"
19-
usage_app_version: "{{ source('apple_store', 'usage_app_version_source_type_report') }}"
15+
downloads_territory: "{{ source('apple_store', 'downloads_territory_source_type_report') }}"
2016
sales_account: "{{ source('apple_store', 'sales_account') }}"
2117
sales_subscription_events: "{{ source('apple_store', 'sales_subscription_event_summary') }}"
2218
sales_subscription_summary: "{{ source('apple_store', 'sales_subscription_summary') }}"
19+
usage_app_version: "{{ source('apple_store', 'usage_app_version_source_type_report') }}"
20+
usage_device: "{{ source('apple_store', 'usage_source_type_device_report') }}"
21+
usage_platform_version: "{{ source('apple_store', 'usage_platform_version_source_type_report') }}"
22+
usage_territory: "{{ source('apple_store', 'usage_territory_source_type_report') }}"
2323
apple_store_country_codes: "{{ ref('apple_store_country_codes') }}"
2424
apple_store__subscription_events:
2525
- 'Renew'

docs/catalog.json

+1-1
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)