-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[CT-3168] [Bug] dbt compile is throwing Object Not Found Error #8733
Comments
hey @ankitsr92 thanks for raising. the above paraphrased quote brought me back to a time when I also believed the same thing should be happening (wish I could link to me asking basically the same question). Fortunately, someone the issue I raise believed before someone else illuminated the truth to me. so here's me passing this knowledge on. It comes down to the convolving the ideas of
dbt uses the term "compile" in a way that's confusing to most software engineers. the reason being is that in dbt, compilation is actually a subset of execution. The reason being that dbt allows for what we call "introspective queries". The Rough definition of parsiing
In a project absent of introspective queries, dbt is capable of parsing without needing to connect to the target database. However, introspective queries throw a wrench into this beautiful separation of concerns because resolving them requires connecting to the database. So now we're executing? Yep IIRC, what Another weird thing about compile is that it doesn't run in DAG order, but rather concurrently up to the thread limit. So if one model’s templated SQL depends on an introspective query that expects another model to have already been materialized, this can lead to errors. I think this is what you're seeing where you are expecting dbt compile to know that There's a great internal doc with more detail on this that you've inspired us to get out in the open. We hope to have this out in the next week or so. In the meantime, my recommendation here would be to step back and frame the problem you are trying to solve. You've certainly learned a lot about how dbt works, but my hunch is that if you phrase it from the perspective of the business problem you are trying to accomplish, that folks in the power user of the community Slack will be able to help you out. I'm going to close this issue, but reply back if you think there's something here that I'm missing. |
@ankitsr92 here's some docs that we're working on to explain parsing vs. compilation vs. execution/runtime: #8744
Update: merged version of those docs here. |
Is this a new bug in dbt-core?
Current Behavior
I am running DBT COMPILE and it is failing with error,
Encountered an error: Runtime Error Database Error in model Test_Model (models/staging/views/Test_Model.sql) 002003 (02000): SQL compilation error: Schema 'TEST_DB.TEST' does not exist or not authorized.
The model is calling a Macro within.
Test_Mode.sql
The Macro is using dbt_utils.get_single_value(sql_statement) to get some data from a table
I added if execute at multiple places to avoid this compilation when running dbt compile. But still it is trying to compile the sqls. If I run DBT RUN it will run everything since these dependent models will be created. But as part of deployment into upper env dbt compile is executed which will fail the deployment.
Any known issues with if execute statement?
DBT 1.5 version is being used.
Expected Behavior
DBT COMPILE should not compile SQL within the IF EXECUTE block and not fail.
Steps To Reproduce
Use the code in the Current Behaviour section.
Relevant log output
No response
Environment
Which database adapter are you using with dbt?
snowflake
Additional Context
No response
The text was updated successfully, but these errors were encountered: