Ref Functions

Ref Functions

These are used to generate fully qualified database object names in the context of the current environment they're in and to build relationships in the DAG that orchestrate node execution.

Ref

Syntax - ref('<location_name>','<node_name>')

ref is used to resolve the fully qualified name of a node from its logical storage location and node name. In addition, this signifies to Coalesce that a reference should be added to the graph topology as a dependency.

This is most commonly used in join conditions to render the fully qualified node name.

Example - {{ ref('STG','CUSTOMER') }} resolves to → ”myDB”.”mySCHEMA”.”CUSTOMER”

Ref_link

Syntax - ref_link('<location_name>','<node_name>')

ref_link is used to signal to Coalesce that a reference should be added to the graph topology as a dependency. However, unlike ref this does not produce any string within the rendered template.

This is most commonly used to create a dependency on the execution of a node, without directly referencing that node in the user's SQL. For example, to force a node to run before the current node, the user would reference the node with ref_link in the JOIN tab of the down stream node.

Example - {{ ref_link('STG','CUSTOMER') }} resolves to → (empty string)

Ref_no_link

Syntax - ref_no_link('<location_name>','<node_name>')

ref_no_link is used to resolve the fully qualified name of a node from its logical storage location and node name. However, unlike ref this does not add a reference to the graph topology.

This is most commonly used when referencing the fully qualified name of current node within its own template. Without ref_no_link, a dependency cycle would be created, which is not allowed.

Example - {{ ref_no_link('STG','CUSTOMER') }} resolves to → ”myDB”.”mySCHEMA”.”CUSTOMER”

You can also find example usage in the Stage-Base Templates section of our User-defined Nodes (UDNs) article.