Run the model not more often than once per day.

The problem I’m having

The context of why I’m trying to do this

We have a model that takes significant time to run and we would like to run this particular model not more often than daily, even though the dbt run can be triggered more often.

What I’ve already tried

I’ve created a table for logging model execution (model_name, execution_timestamp).
I use macros to query the table using model_name input parameter and limit the output to today timestamp records.
I use macros sql query result in a model to get the number of records; if it’s zero then execute the model.

Some example code or error messages

The code will follow

Even though the manual check shows that the query returns 1, the same query inside of dbt model returns None (not zero, just None). I scratch my head and added a lot of debug trying to see what’s going on.

I’ll update the post with all details shortly.