Skip to content
This repository was archived by the owner on Jan 15, 2026. It is now read-only.

Conversation

@fivetran-catfritz
Copy link
Contributor

@fivetran-catfritz fivetran-catfritz commented Mar 26, 2025

PR Overview

This PR will address the following Issue/Feature:

Submission Checklist

Submitter:

  • Alignment meeting with the reviewer
  • Provide validation details:
    • Validation Steps: Outline how to verify the changes
    • Testing Instructions: Clear steps for running/testing (e.g., scripts, sample data)
    • Focus Areas: Highlight any complex logic or queries needing special attention

Changelog

  • Draft for PR
  • Finalize after PR approval

Validation

  • Recreate error from the Shopify example:

    • Screenshot 2025-03-31 at 3 31 37 PM
  • Issue is resolved with updates:

    • Screenshot 2025-03-31 at 3 35 07 PM
  • Consistency tests pass

    • Screenshot 2025-03-31 at 5 58 48 PM
  • Test plan vs price switch. plan is now correctly selected when price does not exist and the using_* var is not set.

    • Screenshot 2025-03-31 at 3 36 35 PM

* Update does_table_exist.sql

Usage of adapter.get_relation causes a failure when fivetran/shopify package is also used in a project due to quoting of objects in that package.

Suggestion is to replace adapter.get_relation with api.Relation.create in this macro.

Please see:

oracle/dbt-oracle#5 (comment)

* Update CHANGELOG.md

* Update dbt_project.yml
@fivetran-catfritz fivetran-catfritz self-assigned this Mar 26, 2025
@fivetran-catfritz fivetran-catfritz changed the title Update does_table_exist.sql (#90) Update does_table_exist.sql Mar 26, 2025
@@ -1,17 +1,14 @@
{%- macro does_table_exist(table_name) -%}
{%- if execute -%} -- returns true when dbt is in execute mode
{%- set ns = namespace(has_table=false) -%} -- declare boolean namespace and default value
Copy link
Contributor Author

@fivetran-catfritz fivetran-catfritz Mar 31, 2025

Choose a reason for hiding this comment

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

ns is never used--removed.

Comment on lines -4 to -11
{%- for node in graph.sources.values() -%} -- grab sources from the dictionary of nodes
-- call the database for the matching table
{%- set source_relation = adapter.get_relation(
database=node.database,
schema=node.schema,
identifier=node.identifier ) -%}
{%- if source_relation == None and node.name | lower == table_name | lower -%}
{{ return(False) }} -- return false if relation identified by the database.schema.identifier does not exist for the given table name
Copy link
Contributor Author

@fivetran-catfritz fivetran-catfritz Mar 31, 2025

Choose a reason for hiding this comment

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

Based on alignment meeting, we'll directly use the values for adapter.get_relation since we have them, which is similar to what is used in Lever.

Comment on lines 7 to 15
{# DEBUG #}
{% if execute %}
{{print('-------- FOR DEBUGGING --------')}}
{{print('The value of stripe_source.does_table_exist(price) is: ' ~ stripe_source.does_table_exist('price'))}}
{{print('The value of stripe_source.does_table_exist(plan) is: ' ~ stripe_source.does_table_exist('plan'))}}
{{print('what is passed to union macro is: '~ price_or_plan)}}
{{print('--------')}}
{% endif %}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will remove before merge.

Copy link
Contributor

Choose a reason for hiding this comment

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

just a reminder

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.

Looks good, just one minor suggestion!

Comment on lines 7 to 15
{# DEBUG #}
{% if execute %}
{{print('-------- FOR DEBUGGING --------')}}
{{print('The value of stripe_source.does_table_exist(price) is: ' ~ stripe_source.does_table_exist('price'))}}
{{print('The value of stripe_source.does_table_exist(plan) is: ' ~ stripe_source.does_table_exist('plan'))}}
{{print('what is passed to union macro is: '~ price_or_plan)}}
{{print('--------')}}
{% endif %}

Copy link
Contributor

Choose a reason for hiding this comment

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

just a reminder

fivetran-catfritz and others added 3 commits April 1, 2025 16:07
Co-authored-by: Renee Li <91097070+fivetran-reneeli@users.noreply.github.com>
Copy link

@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 c9986af into main Apr 2, 2025
8 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants