Hooks on snapshots?

Is it possible to add a post-hook to a snapshot config?

I’m using the snapshot feature to power an external API integration. When certain traits in a users table change, the snapshot writes that row into the snapshot table (check column strategy). I have a macro which then executes the SQL for Snowflake to export that data into S3 where a Lambda picks it up and processes.

At the moment the macro is executed as a project-wide post-hook. But it would be great if that could just be a post-hook of the snapshot itself.

Hey @drew_beaupre - I think post-hooks for snapshots make a lot of sense! We track feature requests on GitHub - feel free to create a new issue if you’re so inclined :slight_smile:

An alternative approach might be to use dbt’s operations. You could write a macro that runs the unload from Snowflake to S3, then call that macro using something like

$ dbt run-operation unload_snapshot_to_s3

The advantage of decoupling the export to S3 from the snapshot process is that you could do the two of these things with separate cadences. If you want to snapshot your data hourly, but only unload to S3 once per day, this mechanism will let you do that.

Yeah the operation is a great point. I can add that as a run step in DBT Cloud when I do my snapshots (and to you point, on a diff schedule if so desired).

Thanks for the tip.

1 Like