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

implement hooks #22

Closed
jthandy opened this issue Apr 14, 2016 · 8 comments
Closed

implement hooks #22

jthandy opened this issue Apr 14, 2016 · 8 comments
Assignees
Milestone

Comments

@jthandy
Copy link
Member

jthandy commented Apr 14, 2016

We need to create "hooks" for the core dbt tasks. Hooks would simply offer the opportunity to write sql-based scripts that would execute before and after the various stages in the dbt commands.

One example use for a hook would be setting grants for a schema and all tables in it to certain users after that schema is created. There's no need for dbt to set those grants itself, this is a generic way to allow users to do this or many other tasks associated with dbt processes.

For now, I could imagine pre and post hooks for dbt run. Since the other commands don't actually interface with the database, I'm not sure that the concept makes as much sense there. If anyone can imagine a use, I'd be open to it though.

In the future it might make sense to implement hooks for individual models, but I don't see the need to do that today.

@drewbanin
Copy link
Contributor

This is a good idea

@drewbanin
Copy link
Contributor

@jthandy is this still something you think we should queue up?

@jthandy
Copy link
Member Author

jthandy commented May 9, 2016

I'd rather make progress on testing for the moment than implement this. This is cool but I don't think it's extremely pressing...

@jthandy
Copy link
Member Author

jthandy commented Jun 9, 2016

I don't feel nearly as much need for this as I once did. The core dbt workflow is clean and getting cleaner. There doesn't seem to be some gaping hole at the moment that could be filled by hooks. We can take this up again in the future if there's a clear need for it.

@jthandy jthandy closed this as completed Jun 9, 2016
@jthandy
Copy link
Member Author

jthandy commented Jul 27, 2016

Ok I take this back. there is a big problem that I need to use this to fix: grant statements! Right now I'm using dbt on one project as a non-admin user, and I need to manually run grant statements on tables every time I do dbt run. Ideally, I would be able to configure a post-hook to accomplish this:

{{config(post-hook="grant select on "+self())}}

@jthandy jthandy reopened this Jul 27, 2016
@jthandy
Copy link
Member Author

jthandy commented Jul 27, 2016

/cc @drewbanin just reopened this. this is being mildly annoying working with contactually right now and querying the views in looker. would be great to resolve this as a part of 0.2.5.0 if at all possible.

@jthandy jthandy mentioned this issue Jul 27, 2016
@jthandy jthandy modified the milestone: 0.4.1 Aug 12, 2016
@drewbanin drewbanin modified the milestone: 0.4.1 Aug 18, 2016
@drewbanin drewbanin modified the milestone: 0.4.2 Aug 27, 2016
@manishkukreja88
Copy link

Can I run multiple SQL statements in an SQL post hook? In addition to granting full access of the table, I also want to log an entry to an audit table in Redshift for logging process start and end times.

@jtcohen6
Copy link
Contributor

jtcohen6 commented Jan 6, 2021

Yes, hooks can accept a list of SQL statements (docs)

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

No branches or pull requests

4 participants