works perfect thanks.
One thing I have my development models in a different BQ project than my tables in production. So it looks this macro only works for me in my development project.
How can I change the macro so it will work on my Production project as well when I run this macro in a job.
All my code is now ‘transferred’ to the right project via a macro: generate_database_name(), see code below.
I think I need to call this macro somewhere from your macro to make it happen, but I don’t know how.
{% macro generate_database_name(custom_database_name=none, node=none) -%}
{{ log("Running generate database name macro") }}
{% set default_database = target.database %}
{% set production_database = 'analytics-prod' %}
{% if custom_database_name %}
{% if target.name == "prod" %}
{{ production_database }}
{% else %}
{{ custom_database_name }}
{% endif %}
{% else %}
{{ default_database }}
{% endif %}
{% endmacro %}