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

bug/renamed-columns #55

Merged
merged 6 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# 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.0.1) for more details.
fivetran-catfritz marked this conversation as resolved.
Show resolved Hide resolved
- 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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would recommend adding a Under the Hood section, and a line for the consistency tests you created.

# 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'
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for creating this here as well!

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
7 changes: 5 additions & 2 deletions packages.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
packages:
- package: fivetran/salesforce_source
version: [">=1.0.0", "<1.1.0"]
# - package: fivetran/salesforce_source
# version: [">=1.1.0", "<1.2.0"]
- git: https://github.com/fivetran/dbt_salesforce_source.git
revision: bug/renamed-columns-option3
warn-unpinned: false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# - package: fivetran/salesforce_source
# version: [">=1.1.0", "<1.2.0"]
- git: https://github.com/fivetran/dbt_salesforce_source.git
revision: bug/renamed-columns-option3
warn-unpinned: false
- package: fivetran/salesforce_source
version: [">=1.1.0", "<1.2.0"]

commit before merge