I have a situation where I want ref to conditionally return database as part of the return value or not. I want this based on examining the model being ref’d and finding the node(s) it depends on.
I’m trying to do this because my team wants to use multiple blue-green processes based on domain, and I want to avoid ‘bad’ cross database references pointing to the blue database.
I’ve been banging my head against the wall trying to understand how to customize the ref function. It’s not even clear to me whether this is something that is possible OR if it’s something that will completely bite me in the ass in the future. I’ve tried to use the graph
object, but I’m not sure if this is correct given the documentation talking about graph
having bad data before parsing the project. And since ref
is like, a big way that dbt parses the project, is what I’m doing even possible?
To summarize my question: Can (or should) I attempt to introspect information about a model when using ref
? Is it possible, and if so, is it really dumb?
EDIT: oh, and also, does anyone know how to like, properly print stuff from the ref
function? Using print()
or log()
works during the parse phase of the project, but not during ‘runtime’. Maybe that’s a misunderstanding on my part of how ref
is functioning though
Thanks