Macro to check record count and raise an exception?

Hello all,

dbt newbie here looking for help :slight_smile:

I would like to call a macro as a post hook after the model is built. This should check the count of records by a specific column and raise an error according to variable set.

Any ideas on how to go about this please? Thanks.

Combing through more documentation, I stumbled across the execute Jinja variable - perhaps this might help? Although I am now curious what would the model in this example (models/order_payment_methods.sql) return?

I know a normal select is wrapped around a CREATE TABLE statement whilst building a model. Does this sql create a table of distinct payment_method?