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/simple hooks #147

Merged
merged 3 commits into from
Sep 19, 2016
Merged

Feature/simple hooks #147

merged 3 commits into from
Sep 19, 2016

Conversation

drewbanin
Copy link
Contributor

@drewbanin drewbanin commented Sep 16, 2016

Implements the simple version of hooks. In your dbt_project.yml file:

models:
  'Test DBT':
    pre-hook: "insert into {{ ref('audit') }} (model, timestamp, status) values ('{{this.table}}', getdate(), 'started')"
    post-hook:
       - "insert into {{ ref('audit') }} (model, timestamp, status) values ('{{this.table}}', getdate(), 'completed')"
       - "grant select on {{this}} to some_user"

There are a couple of new things here:

  • pre hooks run before a model is executed
  • post hooks run after a model is executed
  • hooks can be defined as either a string, or a list of strings
  • these hooks are a part of the transaction which materializes a model. If the transaction fails, the hooks will not be run.
  • the {{ this }} var has been extended such that you can use
    • {{this}} to interpolate "schema"."table"
    • {{this.schema}} to interpolate "schema"
    • {{this.table}} to interpolate "table"
  • hooks are appended to child configs. A hook defined directly beneath the project config will be applied to every model in that project. Hooks defined more specifically will be augmented, not overwritten.
  • hooks are not applied to ephemeral models

cc @jthandy

@drewbanin drewbanin self-assigned this Sep 16, 2016
@drewbanin drewbanin added this to the 0.4.2 milestone Sep 16, 2016
@drewbanin drewbanin merged commit 8d9bd18 into development Sep 19, 2016
@drewbanin drewbanin deleted the feature/simple-hooks branch October 24, 2016 17:25
yu-iskw pushed a commit to yu-iskw/dbt that referenced this pull request Aug 17, 2021
…sion-on-condition

support extra parameter 'condition' on 'expression_is_true' macro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant