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] Trying to compile model in comments #11181

Closed
2 tasks done
Terence-Gawtrey opened this issue Dec 31, 2024 · 4 comments
Closed
2 tasks done

[Bug] Trying to compile model in comments #11181

Terence-Gawtrey opened this issue Dec 31, 2024 · 4 comments
Labels
bug Something isn't working wontfix Not a bug or out of scope for dbt-core

Comments

@Terence-Gawtrey
Copy link

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

When compiling a model with a reference to another model in the comments, it gives a standard model missing error, and will not compile. "Compilation Error in model ... ... depends on a node named"

Note: Dialect is T-SQL
Note: using Azure Dedicated Pools adapter (Azure DW)
Note: commented using "--" style and not "{#" style

Expected Behavior

I expect the model compiler to disregard anything in comments e.g. references.

Steps To Reproduce

  1. Create a model
  2. Add a comment using "--" with reference to another model.
  3. Build and run the model.

Relevant log output

No response

Environment

- OS: Windows
- Python: 3.10.12
- dbt: 1.7.18

Which database adapter are you using with dbt?

other (mention it in "Additional Context")

Additional Context

Azure Dedicated Pools adapter

@Terence-Gawtrey Terence-Gawtrey added bug Something isn't working triage labels Dec 31, 2024
Copy link
Contributor

Thank you for your bug report! Our team is will be out of the office for Christmas and our Global Week of Rest, from December 25, 2024, through January 3, 2025.

We will review your issue as soon as possible after returning.
Thank you for your understanding, and happy holidays! 🎄🎉

If you are a customer of dbt Cloud, please contact our Customer Support team via the dbt Cloud web interface or email [email protected].

@cjohnhanson
Copy link

cjohnhanson commented Jan 8, 2025

We also ran into this behavior in dbt 1.8.4:

We're seeing this:
~~ ~~Encountered an error:~~ ~~Compilation Error~~ ~~Model '<redacted>' (models/<redacted> depends on a node named '<redacted>' which was not found~~ ~~

when the reference in question is commented out in the model that fails to compile.

"This isn't a bug, you shouldn't keep commented out references in your models" I think is a perfectly reasonable response here but intuitively I would have expected compilation to respect comments.

Apparently not a bug, see: #11181 (comment)

@tayloramurphy
Copy link

This is expected AFAIK based on https://docs.getdbt.com/reference/dbt-jinja-functions/ref#forcing-dependencies However dbt is parsing refs it just completely ignores comments.

@dbeatty10
Copy link
Contributor

@tayloramurphy hit the nail on the head: what you are seeing is not a bug, and https://docs.getdbt.com/reference/dbt-jinja-functions/ref#forcing-dependencies is an example of how it is actually a feature used by dbt to give hints to build out the DAG.

If you need/want to comment out some code, you can replace {{ that appear within comments to be something else like { {:

select 1 as id
-- from { { ref("nonexistent_model") }}

This will prevent it from being recognized as Jinja that needs to be templated.

@dbeatty10 dbeatty10 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 10, 2025
@dbeatty10 dbeatty10 added wontfix Not a bug or out of scope for dbt-core and removed triage labels Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix Not a bug or out of scope for dbt-core
Projects
None yet
Development

No branches or pull requests

4 participants