Skip to content
Discussion options

You must be logged in to vote

I found it myself:

{% macro count_all_models() %}
  {% if execute %}
    {% set all_models = graph.nodes.values()
       | selectattr("resource_type", "equalto", "model") | list %}
    {{ return(all_models | length) }}
  {% else %}
    {{ return(0) }}
  {% endif %}
{% endmacro %}

{% macro create_udfs() %}
    {% if selected_resources | length == count_all_models() %}
        {{ create_public_udfs() }}
    {% else %}
        {{ log("Omitting UDF creation, only a subset was selected", info = true) }}
    {% endif %}
{% endmacro %}

More on this: https://docs.getdbt.com/reference/dbt-jinja-functions/selected_resources

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
0 participants