-
Notifications
You must be signed in to change notification settings - Fork 22
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
Update partition logic, add source relation #78
Update partition logic, add source relation #78
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fivetran-avinash thanks for pushing this PR forward! I have a few comments below, let me know if you have any questions!
models/stg_shopify__metafield.sql
Outdated
case when id is null | ||
then row_number() over(partition by source_relation order by updated_at desc) = 1 | ||
else row_number() over(partition by id, source_relation order by updated_at desc) = 1 | ||
end as is_most_recent_record, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same note here, we should include the order by field in the null
case when logic.
case when id is null | |
then row_number() over(partition by source_relation order by updated_at desc) = 1 | |
else row_number() over(partition by id, source_relation order by updated_at desc) = 1 | |
end as is_most_recent_record, | |
case when id is null and updated_at is null | |
then row_number() over(partition by source_relation) = 1 | |
else row_number() over(partition by id, source_relation order by updated_at desc) = 1 | |
end as is_most_recent_record, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An order by
is actually required on partitions in Databricks and Snowflake, so I added an order by source relation
to the partition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fivetran-joemarkiewicz PR ready for re-review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved! Changes look good but I have one comment to update the CHANGELOG wording a bit.
CHANGELOG.md
Outdated
[PR #78](https://github.com/fivetran/dbt_shopify_source/pull/78) introduces the following changes: | ||
|
||
## 🚨 Breaking Changes 🚨 | ||
- Added `source_relation` to the `partition_by` clauses that determine the `is_most_recent_record` in the `stg_shopify__metafield` and `stg_shopify__abandoned_checkout_discount_code` tables. If the user is leveraging the union feature, this could change data values, so would recommend a `dbt run --full-refresh` in this case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A full refresh is really only needed if there is an incremental model. Since this is not an incremental model we should remove that blurb.
- Added `source_relation` to the `partition_by` clauses that determine the `is_most_recent_record` in the `stg_shopify__metafield` and `stg_shopify__abandoned_checkout_discount_code` tables. If the user is leveraging the union feature, this could change data values, so would recommend a `dbt run --full-refresh` in this case. | |
- Added `source_relation` to the `partition_by` clauses that determine the `is_most_recent_record` in the `stg_shopify__metafield` and `stg_shopify__abandoned_checkout_discount_code` tables. If the user is leveraging the union feature, this could change data values. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small changelog suggestion!
CHANGELOG.md
Outdated
[PR #78](https://github.com/fivetran/dbt_shopify_source/pull/78) introduces the following changes: | ||
|
||
## 🚨 Breaking Changes 🚨 | ||
- Added `source_relation` to the `partition_by` clauses that determine the `is_most_recent_record` in the `stg_shopify__metafield` and `stg_shopify__abandoned_checkout_discount_code` tables. If the user is leveraging the union feature, this could change data values. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm seeing the col is called index
in the abandoned_checkout table.
- Added `source_relation` to the `partition_by` clauses that determine the `is_most_recent_record` in the `stg_shopify__metafield` and `stg_shopify__abandoned_checkout_discount_code` tables. If the user is leveraging the union feature, this could change data values. | |
- Added `source_relation` to the `partition_by` clauses that determine the `is_most_recent_record` in the `stg_shopify__metafield` table and `index` in the `stg_shopify__abandoned_checkout_discount_code` table. If the user is leveraging the union feature, this could change data values. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fivetran-catfritz Updated!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fivetran-catfritz Changes applied!
CHANGELOG.md
Outdated
[PR #78](https://github.com/fivetran/dbt_shopify_source/pull/78) introduces the following changes: | ||
|
||
## 🚨 Breaking Changes 🚨 | ||
- Added `source_relation` to the `partition_by` clauses that determine the `is_most_recent_record` in the `stg_shopify__metafield` and `stg_shopify__abandoned_checkout_discount_code` tables. If the user is leveraging the union feature, this could change data values. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fivetran-catfritz Updated!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
PR Overview
This PR will address the following Issue/Feature: [#77]
This PR will result in the following new package version:
dbt_shopify_source v0.10.1
Please detail what change(s) this PR introduces and any additional information that should be known during the review of this PR:
🐛 Bug Fixes 🪛
source_relation
to thepartition_by
clauses that determine theis_most_recent_record
in thestg_shopify__metafield
andstg_shopify__abandoned_checkout_discount_code
tables.stg_shopify__metafield
andstg_shopify__abandoned_checkout_discount_code
to account for null table Redshift errors when handling null field cases.🚘 Under The Hood 🚘
integration_tests/dbt_project.yml
to ensure local testing passed on null cases.PR Checklist
Basic Validation
Please acknowledge that you have successfully performed the following commands locally:
Before marking this PR as "ready for review" the following have been applied:
Detailed Validation
Please acknowledge that the following validation checks have been performed prior to marking this PR as "ready for review":
See Height ticket.
Standard Updates
Please acknowledge that your PR contains the following standard updates:
dbt Docs
Please acknowledge that after the above were all completed the below were applied to your branch:
If you had to summarize this PR in an emoji, which would it be?
🏃🏽♂️