Skip to content

Commit

Permalink
bug/renamed-columns (#55)
Browse files Browse the repository at this point in the history
* bug/renamed-columns

* regen docs

* update comments

* Update CHANGELOG.md

Co-authored-by: Avinash Kunnath <108772760+fivetran-avinash@users.noreply.github.com>

* update changelog and bump packages

---------

Co-authored-by: Avinash Kunnath <108772760+fivetran-avinash@users.noreply.github.com>
  • Loading branch information
fivetran-catfritz and fivetran-avinash authored Jul 15, 2024
1 parent 614880a commit e945a33
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 51 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# dbt_salesforce v1.1.0
[PR #55](https://github.com/fivetran/dbt_salesforce/pull/55) includes the following updates:

## 🚨 Breaking Change 🚨
- This change is made breaking due to changes made in the source package. See the [v1.1.0 dbt_salesforce_source release notes](https://github.com/fivetran/dbt_salesforce_source/releases/tag/v1.1.0) for more details.
- Added logic to support user-specified scenarios where the Fivetran Salesforce connector syncs column names using the original Salesforce API naming convention. For example, while Fivetran typically provides the column as `created_date`, some users might choose to receive it as `CreatedDate` according to the API naming. This update ensures the package is automatically compatible with both naming conventions.
- Specifically, the package now performs a COALESCE, preferring the original Salesforce API naming. If the original naming is not present, the Fivetran version is used instead.
- Renamed columns are now explicitly cast to prevent conflicts during the COALESCE.
- ❗This change is considered breaking since the resulting column types may differ from prior versions of this package.

## Under the hood
- Added validation test to ensure the final column names generated before and after this update remain the same.

# dbt_salesforce v1.0.2
[PR #52](https://github.com/fivetran/dbt_salesforce/pull/52) includes the following updates:

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Include the following salesforce package version in your `packages.yml`
```yaml
packages:
- package: fivetran/salesforce
version: [">=1.0.0", "<1.1.0"] # we recommend using ranges to capture non-breaking changes automatically
version: [">=1.1.0", "<1.2.0"] # we recommend using ranges to capture non-breaking changes automatically
```

Do NOT include the `salesforce_source` package in this file. The transformation package itself has a dependency on it and will install the source package as well.
Expand Down Expand Up @@ -287,7 +287,7 @@ This dbt package is dependent on the following dbt packages. For more informatio
```yml
packages:
- package: fivetran/salesforce_source
version: [">=1.0.0", "<1.1.0"]
version: [">=1.1.0", "<1.2.0"]
- package: fivetran/fivetran_utils
version: [">=0.4.0", "<0.5.0"]
- package: dbt-labs/dbt_utils
Expand Down
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
config-version: 2
name: 'salesforce'
version: '1.0.2'
version: '1.1.0'
require-dbt-version: [">=1.3.0", "<2.0.0"]
models:
salesforce:
Expand Down
2 changes: 1 addition & 1 deletion docs/catalog.json

Large diffs are not rendered by default.

37 changes: 5 additions & 32 deletions docs/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/manifest.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/run_results.json

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
name: 'salesforce_integration_tests'
version: '1.0.2'
version: '1.1.0'
config-version: 2

profile: 'integration_tests'

models:
salesforce:
materialized: table
+schema: "salesforce_{{ var('directed_schema','dev') }}"
+materialized: table
+schema: "salesforce_{{ var('directed_schema','dev') }}"

vars:
# enable history models when generating docs!
Expand Down
60 changes: 60 additions & 0 deletions integration_tests/tests/consistency/consistency_columns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{{ config(
tags="fivetran_validations",
enabled=var('fivetran_validation_tests_enabled', false)
) }}

/* This test is to make sure the final columns produced are the same between versions.
Only one test is needed since it will fetch all tables and all columns in each schema.
!!! THIS TEST IS WRITTEN FOR BIGQUERY!!! */
{% if target.type == 'bigquery' %}
with prod as (
select
table_name,
column_name,
data_type
from {{ target.schema }}_salesforce_prod.INFORMATION_SCHEMA.COLUMNS
),

dev as (
select
table_name,
column_name,
data_type
from {{ target.schema }}_salesforce_dev.INFORMATION_SCHEMA.COLUMNS
),

prod_not_in_dev as (
-- rows from prod not found in dev
select * from prod
except distinct
select * from dev
),

dev_not_in_prod as (
-- rows from dev not found in prod
select * from dev
except distinct
select * from prod
),

final as (
select
*,
'from prod' as source
from prod_not_in_dev

union all -- union since we only care if rows are produced

select
*,
'from dev' as source
from dev_not_in_prod
)

select *
from final

{% else %}
{{ print('This is written to run on bigquery. If you need to run on another warehouse, add another version for that warehouse') }}

{% endif %}
32 changes: 24 additions & 8 deletions integration_tests/tests/consistency/consistency_daily_activity.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,41 @@
with prod as (
select *
from {{ target.schema }}_salesforce_prod.salesforce__daily_activity
where date(date_day) < date({{ dbt.current_timestamp() }})
),

dev as (
select *
from {{ target.schema }}_salesforce_dev.salesforce__daily_activity
where date(date_day) < date({{ dbt.current_timestamp() }})
),

final as (
-- test will fail if any rows from prod are not found in dev
(select * from prod
prod_not_in_dev as (
-- rows from prod not found in dev
select * from prod
except distinct
select * from dev
),

dev_not_in_prod as (
-- rows from dev not found in prod
select * from dev
except distinct
select * from dev)
select * from prod
),

final as (
select
*,
'from prod' as source
from prod_not_in_dev

union all -- union since we only care if rows are produced

-- test will fail if any rows from dev are not found in prod
(select * from dev
except distinct
select * from prod)
select
*,
'from dev' as source
from dev_not_in_prod
)

select *
Expand Down
2 changes: 1 addition & 1 deletion packages.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
packages:
- package: fivetran/salesforce_source
version: [">=1.0.0", "<1.1.0"]
version: [">=1.1.0", "<1.2.0"]

0 comments on commit e945a33

Please sign in to comment.