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/add legacy support #27

Merged
merged 17 commits into from
Oct 28, 2024
Merged

Bug/add legacy support #27

merged 17 commits into from
Oct 28, 2024

Conversation

fivetran-catfritz
Copy link
Contributor

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

PR Overview

This PR will address the following Issue/Feature:

This PR will result in the following new package version:

  • v0.7.0 due to schema changes

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

Features

  • For Fivetran Lever connectors created on or after July 27, 2024, the USER and INTERVIEWER_USER source tables have been renamed to USERS and INTERVIEW_USER, respectively. This package now prioritizes the USERS and INTERVIEW_USER tables if available, falling back to USER and INTERVIEWER_USER if not.

    • To continue using the USER and/or INTERVIEWER_USER tables, set the variables lever__using_users and/or lever__using_interview_user to false in your dbt_project.yml.
    • For more information, refer to the July 2024 connector release notes and the related README section.
  • Introduced the ability to union source data from multiple Lever connectors. For more details, see the related README section.

Bug fixes

  • Fixed an issue where the dbt package would error due to a missing CONTACT_LINK source table for users without source data, even though it was enabled in the Fivetran Connector. A null-filled table will now be generated in such cases.

Under the hood

  • Updated temporary models to union source data using the fivetran_utils.union_data macro.
  • Added the source_relation column in each staging model to identify the origin of each field, utilizing the fivetran_utils.source_relation macro.
  • Updated tests to include the new source_relation column.

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:

  • Similar updates as found in THIS Recharge PR.

Missing contact_link

  • Simulated CONTACT_LINK as a missing source, and the null table is properly created.
    Screenshot 2024-10-21 at 5 36 15 PM

user vs users and interviewer_user vs interview_user

  • Include both versions as seeds to test both versions of each source. Snippet from run_models.sh
dbt run --target "$db" --full-refresh
dbt test --target "$db"
dbt run --vars '{lever__using_users: false, lever__using_interview_user: false, lever_using_posting_tag: false, lever_using_requisitions:false}' --target "$db" --full-refresh
dbt test --vars '{lever__using_users: false, lever__using_interview_user: false, lever_using_posting_tag: false, lever_using_requisitions:false}' --target "$db"

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

💃

@fivetran-catfritz fivetran-catfritz self-assigned this Oct 17, 2024
Comment on lines -7 to -8
lever_using_posting_tag: true
lever_using_requisitions: true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are true by default, so should not be included here.

Copy link
Contributor

@fivetran-reneeli fivetran-reneeli left a comment

Choose a reason for hiding this comment

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

Thanks @fivetran-catfritz ! Just had some comments

CHANGELOG.md Outdated Show resolved Hide resolved
integration_tests/dbt_project.yml Show resolved Hide resolved
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 @fivetran-reneeli! I have updated.

integration_tests/dbt_project.yml Show resolved Hide resolved
Copy link
Contributor

@fivetran-reneeli fivetran-reneeli left a comment

Choose a reason for hiding this comment

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

Just remembered one thing-- to uncollapse the dropdowns in the README. Other than that, looks good to go!

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 thanks for working through this PR! I have a few change requests and comments before this is ready to go. Let me know if you have any questions. Thanks!

README.md Outdated Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
- name: opportunity_id
description: Unique ID of the opportunity.
tests:
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason the not_null test was removed for this field? The unique combo of columns doesn't test if the field is not null. We should probably add that back in.

Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment for the other fields that had the not_null test removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added these back.

Comment on lines 1 to 12
{{
fivetran_utils.union_data(
table_identifier='interviewer_user',
database_variable='lever_database',
schema_variable='interview_user' if var('lever__using_interview_user', lever_source.does_table_exist('interview_user')) else 'interviewer_user',
default_database=target.database,
default_schema='lever',
default_variable='interview_user' if var('lever__using_interview_user', lever_source.does_table_exist('interview_user')) else 'interviewer_user',
union_schema_variable='lever_union_schemas',
union_database_variable='lever_union_databases'
)
}}
Copy link
Contributor

Choose a reason for hiding this comment

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

For some reason this isn't working as I would expect when testing on two different schemas (one with interviewer_user and one with interview_user. It seems to work when interviewer_user is present, but not interview_user.

Strangely enough, the users vs user works without an issue. Would you be able to look into this and see what could be the cause or if I may be missing something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh boy I finally figured out I pasted the switch logic into the wrong line... 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.

@fivetran-joemarkiewicz Thanks for the review. Made the updates!

Comment on lines 1 to 12
{{
fivetran_utils.union_data(
table_identifier='interviewer_user',
database_variable='lever_database',
schema_variable='interview_user' if var('lever__using_interview_user', lever_source.does_table_exist('interview_user')) else 'interviewer_user',
default_database=target.database,
default_schema='lever',
default_variable='interview_user' if var('lever__using_interview_user', lever_source.does_table_exist('interview_user')) else 'interviewer_user',
union_schema_variable='lever_union_schemas',
union_database_variable='lever_union_databases'
)
}}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh boy I finally figured out I pasted the switch logic into the wrong line... updated!

CHANGELOG.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
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.

LGTM

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.

@fivetran-joemarkiewicz I added the null tests back!

- name: opportunity_id
description: Unique ID of the opportunity.
tests:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added these back.

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.

Thanks @fivetran-catfritz! Approved with one last request to add an additional entry to the CHANGELOG for the test modification/updates.

## Under the hood
- Turned off freshness tests for `USER`/`USERS` and `INTERVIEW_USER`/`INTERVIEWER_USER` to avoid possible conflicts.
- Updated temporary models to union source data using the `fivetran_utils.union_data` macro.
- Added the `source_relation` column in each staging model to identify the origin of each field, utilizing the `fivetran_utils.source_relation` macro.
Copy link
Contributor

Choose a reason for hiding this comment

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

Some staging models had the not_null test added when it was previously being tested. Can we include a callout in here to mention this. No need to be explicit, but an blanket statement saying we made sure to add not_null tests for the relevant fields within each staging model.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added!

@fivetran-catfritz fivetran-catfritz merged commit 72cbe9a into main Oct 28, 2024
7 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