DBT testing fact relationship while building dim

I am relatively new to dbt and am having trouble with relationship tests failing on dimension table builds before the fact table build runs. I have looked thru the docs but haven’t found an explanation for what is happening.

I have my job set up to build my dimensions first, and then the fact table. The fact table has relationship tests to the dims. Why on EARTH is the dim build running the FACT table relationship tests? It is attempting to run the fact relationship tests and complaining that the fact table model doesn’t exist yet - well of course it doesn’t - it hasn’t been built yet.

I have come from a traditional Kimball DW background - build the dims, then load facts and check for fact keys that don’t exist on the dims and handle them as necessary. The idea of a dim build checking the fact model/view makes no sense to me. What am I doing wrong here? Can anyone maybe point me to somewhere in the docs that would thoroughly explain this topic?

Secondly - is there syntax for the dbt command that will run the build and skip all the relationship tests?

Perhaps one of the non-eager indirect selection modes will work for you? https://docs.getdbt.com/reference/global-configs/indirect-selection

Note: @Owen originally posted this reply in Slack. It might not have transferred perfectly.

Thanks, I think setting this to cautious may give me the behavior I would expect. I will give this a try. It still baffles me why even in eager mode it would try to validate children when building a parent in a relationship. That will never work.

Also, I see that just using dbt run appears not to execute the tests. I had thought I had tried that unsuccessfully, but trying it again I see it did skip the test.

Update - using other indirect-selection modes do not work. It appears that only the eager mode will perform relationship tests so while setting it to a lower mode does stop the dims from running the fact table relationship tests - when the fact table loads it doesn’t run them either. Therefore it would seem I have to supply this value on the command line individually for dims vs facts.

Frankly, this seems like a bug to me.

Is there a reason you cannot use dbt build to run your dimension and fact tables in a single invocation? Doing so would run the relationships test after the dim and fact both successfully build, which sounds like your desired behavior.

Note: @Owen originally posted this reply in Slack. It might not have transferred perfectly.

The models don’t refer to each other directly, and I don’t want to build the entire ‘project’ in a single command as there are other fact tables in there that have different timing constraints.