-
Notifications
You must be signed in to change notification settings - Fork 31
Conversation
* 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
| @@ -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 | |||
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.
ns is never used--removed.
| {%- 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 |
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.
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.
| {# 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 %} | ||
|
|
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.
Will remove before merge.
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.
just a reminder
fivetran-reneeli
left a comment
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.
Looks good, just one minor suggestion!
| {# 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 %} | ||
|
|
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.
just a reminder
Co-authored-by: Renee Li <91097070+fivetran-reneeli@users.noreply.github.com>
fivetran-avinash
left a comment
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.
Good to go! One request to update the LICENSE.
PR Overview
This PR will address the following Issue/Feature:
Submission Checklist
Submitter:
Changelog
Validation
Recreate error from the Shopify example:
Issue is resolved with updates:
Consistency tests pass
Test
planvspriceswitch.planis now correctly selected whenpricedoes not exist and theusing_*var is not set.