Create custom ref()/source() macro

As part of my work I need to create a macro similar to ref() and/or source(), but with a few tweaks. I tried looking at the GitHub repo, but I can’t find their source code. Is there any way I can access them, or am I asking for confidential information?

Thank you in advance :slight_smile:

ref and source aren’t macros, they’re bulitin functions - there are both parse-time and runtime implementations. They’re not confidential or anything, dbt is open source! But I don’t think they’ll be useful for your needs unless you plan on forking dbt, you can’t really override them. They’re hooked pretty deeply into dbt internals.

Both parse and run-time implement instances of this base class - parser.ref, parser.source, runtime.ref, and runtime.source. They’re instantiated with information about the model for each node being parsed or run, and then their __call__ is what does the work for that particular phase of dbt.

1 Like

Thank you very much :slight_smile: