Questions on pre-hook

Hi,
I have 2 questions on pre-hook:

  1. I need to put a table as source, and also use it as a model. So the table needs to exist at the first beginning. I tried to use pre_hook to run DDL in the table model. I found the pre-hook will run so table will be created but the model will fail and complain the table has existed. The reason should be somehow dbt will not create the backup table when it doesn’t exist at first. Is there a way to fix this?

  2. I expect the pre-hook to run the DDL can be a separate step in airflow generated by dbt. Is there a way to do this?

Thanks

On the face of it, it seems like you might be doing something that might be better expressed as an incremental model, although without more context it’s hard to say definitively. I would look at that option first, because dbt is trying to build a DAG, and the A in DAG stands for Acyclic, eg there are no cycles in the graph.

Our requirements are:

-- model1
select ... something join model2
--model2
select * from model1 where last partition

We have to put model2 as source, else dbt complains cycle.