Don't run hooks on run --select #11215
-
Hi, I'm searching for a way to omit running hooks when using Is there a way to check if Might it be possible to check whether we execute more than one model? |
Beta Was this translation helpful? Give feedback.
Answered by
nstein-gpjoule
Jan 16, 2025
Replies: 1 comment
-
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 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
nstein-gpjoule
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found it myself:
More on this: https://docs.getdbt.com/reference/dbt-jinja-functions/selected_resources