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/null customer tags #89

Merged
merged 4 commits into from
Oct 21, 2024
Merged

Bug/null customer tags #89

merged 4 commits into from
Oct 21, 2024

Conversation

fivetran-catfritz
Copy link
Contributor

@fivetran-catfritz fivetran-catfritz commented Oct 18, 2024

PR Overview

This PR will address the following Issue/Feature:

  • Internal ticket

This PR will result in the following new package version:

  • 0.13.2 non-breaking since no schema changes.

Please provide the finalized CHANGELOG entry which details the relevant changes included in this PR:

Bug Fixes

  • Fixed an issue where the shopify__customers model incorrectly displayed NULL values for the customer_tags field for customers without orders. Updated the logic to ensure customer tags are retrieved even if no orders have been placed for that customer.

Under the Hood

  • Updated seed data to include customers without orders, verifying that their tags are correctly pulled through.
  • Added consistency and integrity tests for the shopify__customers model to ensure accurate handling of customer tags for all customers.

PR Checklist

Basic Validation

Please acknowledge that you have successfully performed the following commands locally:

  • dbt run –full-refresh && dbt test
  • dbt run (if incremental models are present) && dbt test

Before marking this PR as "ready for review" the following have been applied:

  • The appropriate issue has been linked, tagged, and properly assigned
  • All necessary documentation and version upgrades have been applied
  • docs were regenerated (unless this PR does not include any code or yml updates)
  • BuildKite integration tests are passing
  • Detailed validation steps have been provided below

Detailed Validation

Please share any and all of your validation steps:

  • Simulated issue with seed data and confirm the update corrects this. See prod vs dev for customer_id '3584045351010'.
    Screenshot 2024-10-18 at 11 17 26 AM

  • Newly added validation tests are:

    • integrity_customers: passes
    • consistency_customers: expected not to pass since this update corrects an issue in prod
      Screenshot 2024-10-18 at 3 43 36 PM

If you had to summarize this PR in an emoji, which would it be?

💃

@fivetran-catfritz fivetran-catfritz self-assigned this Oct 18, 2024
Copy link
Contributor

@fivetran-joemarkiewicz fivetran-joemarkiewicz left a comment

Choose a reason for hiding this comment

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

@fivetran-catfritz this looks good to me! I do have one request to update the integrity test. Other than that, this code update looks good to go from my point of view! Thanks!

@@ -24,6 +24,5 @@ public_models: [
"shopify__products",
"shopify__transactions",
"shopify__customers",
"shopify__order_lines",
"shopify__line_item_enhanced"
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for remembering to make this change!

Comment on lines 15 to 20
select
customer_id,
count(*) as transform_customer_tag_count
from {{ target.schema }}_shopify_dev.shopify__customers
where customer_tags is not null
group by 1
Copy link
Contributor

Choose a reason for hiding this comment

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

This integrity test produces inaccurate results. This will count the number of tags in the source (accurate); however, it's only counting the number of rows for a given customer in the transform (inaccurate since this should always be 1). Therefore, this will result in a failed test if a given customer has multiple tags associated with them.

image

Instead we can adjust the transformation component of this test to check the items in the array and then count those. This way if a customer has 3 tags in the source, then there should be 3 items in the customer_tags array in the transform.

Suggested change
select
customer_id,
count(*) as transform_customer_tag_count
from {{ target.schema }}_shopify_dev.shopify__customers
where customer_tags is not null
group by 1
select
customer_id,
array_length(split(customer_tags, ',')) as transform_customer_tag_count -- Only BigQuery compatible for the time being
from zz_dbt_joe_shopify_dev.shopify__customers
where customer_tags is not null
group by customer_id, customer_tags

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. I have updated.

Copy link
Contributor Author

@fivetran-catfritz fivetran-catfritz left a comment

Choose a reason for hiding this comment

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

Thanks for the review @fivetran-joemarkiewicz. I updated the test, so moving to release review.

Comment on lines 15 to 20
select
customer_id,
count(*) as transform_customer_tag_count
from {{ target.schema }}_shopify_dev.shopify__customers
where customer_tags is not null
group by 1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you. I have updated.

Copy link
Contributor

@fivetran-avinash fivetran-avinash left a comment

Choose a reason for hiding this comment

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

@fivetran-catfritz fivetran-catfritz merged commit 903e562 into main Oct 21, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants