Im trying to call a macro that takes from one table the max data.
then the macro should use this value in some models, and in some models this value need to
be calculate with other values.
How can I allow declaration of vars in schema.yml for each model and not in dbt_project.yml?
And i want this vars will be a result from a query cause i dont want to access the DB each time.
Thank you
Each model is run independently, there is no shared context between them. This also means that it’s not possible to have a shared variable based on a code calculation. It’s also worth noting that variables can only be declared in dbt_project.yml and have to be set project-wide for a dbt invocation.
How complex is the thing you’re hitting the database for? One workaround for a complex calculation is to write the result to a separate table so you only need to evaluate it once.
This use case comes up from time to time; it would be worth opening a GitHub issue if one doesn’t already exist: Issues · dbt-labs/dbt-core · GitHub