mjirv / dbt-datamocktool

A dbt package for unit testing your SQL analytics models
Apache License 2.0
162 stars 20 forks source link

Support for models that use ephemeral models (mocking input to the ephemeral models) #80

Open clairetaylor352 opened 1 year ago

clairetaylor352 commented 1 year ago

Describe the feature

I assume that what I'm about to describe isn't supported right now, as I can't get it to work.

I have a model (A) that uses an ephemeral model (B), that in turn also uses an ephemeral model. (C). Model C uses a regular model (D) I'd like to unit test A, and mock the input from D, since ephemeral models are effectively just CTEs under the hood.

I get an error: 12:08:46 002003 (42S02): SQL compilation error: 12:08:46 Object 'DBTCTE__B' does not exist or not authorized.

When I tried this on the off chance that it might work!

Describe alternatives you've considered

Mocking and testing the ephemeral models, this is annoying for me though as they have array inputs and outputs, so it's fiddly.

Additional context

I don't think it will be DB specific, but I am using Snowflake.

Who will this benefit?

Anyone who wants to do what I describe above.

Are you interested in contributing this feature?

I could do, but I'm not sure where to start!

mjirv commented 1 year ago

Taking a look at this. Would you be able to post your test yaml for when you tried this but got the error above?