Closed franzoni315 closed 1 year ago
Thanks for raising this, this is completely new to me as I don't use dbt-codegen. You're right about current_model
, it was much more important in early versions of this package but is currently only used for logging purposes. I'll think about the best way to deprecate it since the variable isn't really needed anymore.
In the meantime, you should be able to fix this by using this ref
macro in your project:
{% macro ref(
parent_model,
current_model=this.name if this is defined,
prod_database=var("upstream_prod_database", None),
prod_schema=var("upstream_prod_schema", None),
enabled=var("upstream_prod_enabled", True),
fallback=var("upstream_prod_fallback", False),
env_schemas=var("upstream_prod_env_schemas", False)
) %}
{% if current_model %}
{% do return(upstream_prod.ref(parent_model, current_model, prod_database, prod_schema, enabled, fallback, env_schemas)) %}
{% else %}
{% do return(builtins.ref(parent_model)) %}
{% endif %}
{% endmacro %}
Fixed in version 0.5.0
In my team, we commonly use the macro
generate_model_yaml
from the package dbt-codegen in order to easily generate the yml documentation for a new model.However, while running
dbt run-operation generate_model_yaml --args '{"model_names": [<model_name>]}'
, we had the following error mentioning the altered macroref()
The problem is that in
dbt run-operation
the variablethis
does not seem to exist.The variable
this
is the default value for the variablecurrent_model
, but this seems only to be used in a jinja's log macro.