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] does_table_exist macro failure when a source with a quoted identifier exists #84

Open
2 of 4 tasks
niccoloalexander opened this issue Oct 25, 2024 · 3 comments
Open
2 of 4 tasks
Labels
error:forced status:stale Issue was blocked or had no user response for more than 30 days type:bug Something is broken or incorrect type:wontfix This will not be worked on

Comments

@niccoloalexander
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the issue

Does table exist is searching the entire dbt graph which may include quoted objects. The Snowflake adapter automatically capitalizes these table or view names. And it causes some sort or ambiguity error.

Relevant error log or model output

Compilation Error in model stg_stripe__price_plan_tmp (models/tmp/stg_stripe__price_plan_tmp.sql)
  When searching for a relation, dbt found an approximate match. Instead of guessing 
  which relation to use, dbt will move on. Please delete "DATABASE"."SCHEMA"."quoted_identifier", or rename it to be less ambiguous.
  Searched for: DATABASE.SCHEMA.QUOTED_IDENTIFIER
  Found: "DATABASE"."SCHEMA"."quoted_identifier"
  
  > in macro does_table_exist (macros/does_table_exist.sql)
  > called by model stg_stripe__price_plan_tmp (models/tmp/stg_stripe__price_plan_tmp.sql)

Expected behavior

Successful model run

dbt run -m stg_stripe__price_plan_tmp

Possible solution

Can we make the macro only search for objects inside the stripe database and schema? Why is it searching globally?

dbt Project configurations

vars:
stripe_database: internal_analytics
stripe_schema: stripe

Package versions

package: dbt-labs/codegen
version: 0.12.1
package: dbt-labs/audit_helper
version: 0.12.0
package: calogica/dbt_expectations
version: 0.10.4
package: fivetran/hubspot
version: [">=0.18.0", "<0.19.0"]
package: fivetran/stripe
version: [">=0.15.0", "<0.16.0"]
package: fivetran/facebook_ads
version: [">=0.7.0", "<0.8.0"]
package: fivetran/google_ads
version: [">=0.11.0", "<0.12.0"]
package: fivetran/linkedin
version: [">=0.9.0", "<0.10.0"]

What database are you using dbt with?

snowflake

How are you running this dbt package?

Fivetran Transformations, dbt Core™

dbt Version

Core:

installed: 1.8.6
Plugins:
snowflake: 1.8.3

Additional Context

No response

Are you willing to open a PR to help address this issue?

  • Yes.
  • Yes, but I will need assistance.
  • No.
@fivetran-catfritz
Copy link
Contributor

fivetran-catfritz commented Oct 29, 2024

Hi @niccoloalexander, thanks for reaching out! It appears that this is not isolated to the macro but rather part of a broader challenge with how dbt manages sources in Snowflake. I was able to reproduce the error and resolved it by specifying the quoted identifier using a variable in dbt_project.yml.

To fix the issue, try adding the following to your vars section, ensuring the quotes remain as they are below. This forces dbt to preserve case sensitivity for the identifier. You can apply the same approach to any other source tables that require quoting when using our packages.

vars:
    stripe_price_identifier: "'price'"

You can also refer to this section in our readme. Let me know if that solves your issue!

@fivetran-catfritz
Copy link
Contributor

fivetran-catfritz commented Nov 4, 2024

Hi @niccoloalexander, just following up if you were able to get this working or if you had any questions!

@fivetran-catfritz
Copy link
Contributor

Marking this issue as stale for the time being since there hasn't been activity. If you need to reach our team again, however, please ping us again in this ticket!

@fivetran-catfritz fivetran-catfritz added the status:stale Issue was blocked or had no user response for more than 30 days label Nov 8, 2024
@fivetran-joemarkiewicz fivetran-joemarkiewicz added the type:wontfix This will not be worked on label Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error:forced status:stale Issue was blocked or had no user response for more than 30 days type:bug Something is broken or incorrect type:wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants