Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Disable post-hook on models directory #4105

Closed
1 task done
sfc-gh-pkommini opened this issue Oct 21, 2021 · 2 comments
Closed
1 task done

[Feature] Disable post-hook on models directory #4105

sfc-gh-pkommini opened this issue Oct 21, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@sfc-gh-pkommini
Copy link

Is there an existing feature request for this?

  • I have searched the existing issues

Describe the Feature

I want a way to disable a post-hook enabled at a root level at a sub-directory level.

Describe alternatives you've considered

This is for a directory of custom materializations and hence have considered removing the {{ run_hooks(post_hooks, inside_transaction=True) }} section of the materialization template.

Who will this benefit?

Will benefit people writing custom materializations as they will want to materialize objects that have a different grant mechanism for example.

Are you interested in contributing this feature?

Yes

Anything else?

No

@jtcohen6
Copy link
Contributor

@sfc-gh-pkommini Thanks for opening! This is a totally reasonable request. Today, pre/post hooks are additive when merged, same as tags, and there isn't a way to customize that behavior. I just opened #4108 to describe that problem in more detail.

For the time being, there are a few ways you could work around this limitation:

  • Reorganize your model subdirectories so that you can apply hooks at a subdirectory level, instead of a root level
  • Encode into your hook logic (or macro logic, assuming it calls a macro) a conditional check for whether the current model is configured with an undesirable materialization:
{% macro my_hook_macro() %}

  {% if execute and config.get('materialized') != 'my_custom_materialization' %}
    {{ log("This isn't my custom materialization", info = true) }}
  {% endif %}

{% endmacro %}
models:
  +post-hook: "{{ my_hook_macro() }}"

I'm going to close this in favor of the broader proposal in #4108.

@jtcohen6 jtcohen6 removed the triage label Oct 21, 2021
@sfc-gh-pkommini
Copy link
Author

Good enough for me! 👍

@dbeatty10 dbeatty10 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants