fivetran / dbt_mailchimp

Fivetran's Mailchimp dbt package
https://fivetran.github.io/dbt_mailchimp/
Apache License 2.0
3 stars 5 forks source link

BUG - Mailchimp tests fail to pass #24

Closed CraigWilson-ZOE closed 2 years ago

CraigWilson-ZOE commented 2 years ago

Are you a current Fivetran customer? Craig Wilson, Data Engineering, ZOE

Describe the bug When running the tests in the mailchimp package we are getting the following errors:

Completed with 4 errors and 0 warnings:

Failure in test unique_stg_mailchimp_members_member_id (models/base/schema.yml)
Got 551602 results, configured to fail if != 0

compiled SQL at target/compiled/mailchimp/models/base/schema.yml/schema_test/unique_stg_mailchimp_members_member_id.sql

Failure in test not_null_automation_activities_by_automation_automation_id (models/intermediate/schema.yml)
Got 1 result, configured to fail if != 0

compiled SQL at target/compiled/mailchimp/models/intermediate/schema.yml/schema_test/not_null_automation_activities_by_automation_automation_id.sql

Failure in test unique_automation_activities_by_member_member_id (models/intermediate/schema.yml)
Got 116 results, configured to fail if != 0

compiled SQL at target/compiled/mailchimp/models/intermediate/schema.yml/schema_test/unique_automation_activities_by_member_member_id.sql

Failure in test unique_mailchimp_members_member_id (models/schema.yml)
Got 551679 results, configured to fail if != 0

compiled SQL at target/compiled/mailchimp/models/schema.yml/schema_test/unique_mailchimp_members_member_id.sql

Steps to reproduce

  1. Ensure you have data where a user can subscribe to many lists
  2. Install dbt package for Mailchimp (version: [">=0.3.0", "<0.4.0"])
  3. Run a full dbt run for the Mailchimp package e.g. dbt run --select Mailchimp
  4. run a full dbt test for the Mailchimp package e.g. dbt test --select Mailchimp
  5. See the failing tests

Expected behavior All tests to pass without error

Project variables configuration

vars:
    mailchimp_database: xxxxxxxx --hidden for privacy reasons
    mailchimp_schema: mailchimp
    mailchimp_using_segments: false

Package Version

  - package: fivetran/mailchimp
    version: [">=0.3.0", "<0.4.0"]

Warehouse

- [x] BigQuery - [ ] Redshift - [ ] Snowflake - [ ] Postgres - [ ] Databricks - [ ] Other (provide details below) **Additional context**

When investigating this with the solutions team we found that user can belong to many lists (list_id) and that is the cause of at least one of the errors. This should be added as part of the primary key check. In addition, the mailchimp_members table aggregation seemed to join too many times generating an aggregate with duplicates apart from two distinct fields which seemed to be mutually exclusive: automation_sends and automation_unsubscribes

On the duplicate rows, each of these were 0 on one row and had a number on the other i.e. ROW 1: automation_sends = 6, automation_unsubscribes = 0 ROW 2: automation_sends = 0, automation_unsubscribes = 5

Screenshots

Please indicate the level of urgency

This is impacting our ability to see if we wish to use the Mailchimp data for analysis.

Are you interested in contributing to this package?

fivetran-reneeli commented 2 years ago

Hi @CraigWilson-ZOE , apologies for the wait, the team was out last week. I'll be taking a look this week!

fivetran-reneeli commented 2 years ago

Hi @CraigWilson-ZOE Just an update that the dbt v1 upgrades delayed some progress; we are still looking into this!

fivetran-reneeli commented 2 years ago

Hey @CraigWilson-ZOE! Apologies again for the delay; we were able to work on this a bit and see that it passed on our local runs. However since we don't have real data, it would be great if you could try running the branch and let me know if the tests pass/ all else looks fine?

Just drop this in your packages.yml:

packages:
    - git: https://github.com/fivetran/dbt_mailchimp_source.git
      revision: bug/unique_tests
      warn-unpinned: false

Thank you again for bringing this issue up with us 😄

fivetran-reneeli commented 2 years ago

Hi @CraigWilson-ZOE, just checking to see if you've been notified!

fivetran-reneeli commented 2 years ago

Hi Craig, we're going to go ahead and close this issue for now without merging the branch. You can run with this bug/unique_tests branch; once we are notified that the branch solves the issue we can merge it; if it doesn't resolve the issue, we can reopen this!

Just make sure to drop this in your packages.yml:

packages:
    - git: https://github.com/fivetran/dbt_mailchimp_source.git
      revision: bug/unique_tests
      warn-unpinned: false