-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[Feature] Recognize API Relation Table Used in SQL Header as Parent of Model #11038
Comments
Thanks for reaching out @aboomer07 ! What you described sounds like the expected behavior to me. This is because dbt will only recognize dependencies that come from a call to the Is there a reason why you can't create a source and then utilize it like the following?
sources:
- name: <my_source_name> # often same as <my_schema>, but you can name the source whatever you want
database: <my_database>
schema: <my_schema>
tables:
- name: <my_identifier>
-- ...
-- depends_on: {{ source("<my_source_name>", "<my_identifier>") }}
-- ... I didn't try one way or another with placing the source reference within the |
Thanks for getting back! I now see that wasn't quite enough information on my part, but in general that makes sense what you're saying about dynamic graph building. So I have a couple more things going on here, I have both a DBT project ( So
So following the DAG I have
Then Hopefully this makes sense? I found a workaround for now, and if this isn't a good pattern to pursue then I'm fine with closing this issue! I guess this is also sort of a BigQuery issue, since this kind of pattern is only needed for specifying the partition filters. |
Thank you for that additional context @aboomer07 💡
This would be a feature request rather than a bug report, so I'm going to update the title accordingly. The ability to pass in a list of table dependencies is not something we'd be interested in adopting especially since you have a workaround so I'm going to close this as "not planned". |
Is this a new bug in dbt-core?
Current Behavior
In one of my DBT models
my_downstream_model
, I am defining a table reference usingapi.relation.create
like this:This table is then used to leverage the declare variables functionality of BigQuery within a SQL header. I am doing this since the main table used in the model is a hive partitioned external table, so declaring the partitions as a variable greatly reduces the query cost compared to having the partitions be defined by the result of another query.
The SQL header call looks something like this:
my_table
is not used anywhere else in the main model query, and it is not recognized as a parent ofmy_downstream_model
.Is this the intended behavior? I also tried to set it as a dependency manually, doing
-- depends_on: {{ my_table }}
but that didn't get it to be recognized as a parent either.Expected Behavior
My expectation was that
my_table
would be recognized as a parent ofmy_downstream_model
, so that the DAG execution ordering would be correct.Steps To Reproduce
Create a DBT SQL model with
my_table
defined as above, and use it in a SQL header call as I defined. I randbt ls --select=my_table+
andmy_downstream_model
was not in its list of dependenciesRelevant log output
No response
Environment
Which database adapter are you using with dbt?
bigquery
Additional Context
No response
The text was updated successfully, but these errors were encountered: