ref
and source
functions both return a Relation
object
#6331
Labels
content
Improvements or additions to content
improvement
Use this when an area of the docs needs improvement as it's currently unclear
Contributions
Link to the page on docs.getdbt.com requiring updates
It seems to me that there is an overarching concept that encompasses the
ref
andsource
functions. But we don't have a name for this concept or a page that covers it.See the docs for the
relation
config in snapshots as an example of a config that can take either aref
or asource
as an argument. This same thing applies to given inputs in unit tests (although we don't currently have any examples of usingsource
). See alsodepends_on
for exposures.Spitballing, maybe "relation functions" is a decent name? The docs for exposures call these "refable", but sources and metrics aren't in the list of refable node types.
Here's a brainstorm of alternative names:
What part(s) of the page would you like to see updated?
The
ref
andsource
functions have very similar behavior.Here's a couple similarities:
Here's some differences:
ref
is for a model, seed, or snapshot whereassource
is just for sourcesref
has a minimum of one argument has optional arguments for project/package and version whereassource
always has exactly two arguments.ref
get itsdatabase
andschema
from thegenerate_database_name
andgenerate_schema_name
macros (which usetarget.database
andtarget.schema
from the target variables) whereassource
hasdatabase
andschema
as part of its definition in YAML.Additional information
This issue is mainly inspired by the
relation
config in snapshots that can be eithersource
orref
:But could also help address this question: https://stackoverflow.com/questions/73784913/dbt-ref-vs-source
Other tie-ins
--favor-state
for sources dbt-core#9599 (comment)ref
calls with the--defer
flag #6332The text was updated successfully, but these errors were encountered: