Skip to content

Commit

Permalink
Merge pull request #925 from dbt-labs/joellabes-patch-4
Browse files Browse the repository at this point in the history
Add load_relation to the adapter docs
  • Loading branch information
joellabes authored Apr 8, 2022
2 parents 357dc05 + 1eb5238 commit 9a96a89
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions website/docs/reference/dbt-jinja-functions/adapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The following functions are available:
- [adapter.get_missing_columns](#get_missing_columns)
- [adapter.expand_target_column_types](#expand_target_column_types)
- [adapter.get_relation](#get_relation)
- [adapter.load_relation](#load_relation)
- [adapter.get_columns_in_relation](#get_columns_in_relation)
- [adapter.create_schema](#create_schema)
- [adapter.drop_schema](#drop_schema)
Expand Down Expand Up @@ -106,6 +107,30 @@ Returns a [Relation](dbt-classes#relation) object identified by the `database.sc

</File>

## load_relation
__Args__:

* `relation`: The [Relation](dbt-classes#relation) to try to load

A convenience wrapper for [get_relation](#get_relation). Returns another copy of the same [Relation](dbt-classes#relation) object, or `None` if the relation does not exist.

**Usage**:

<File name='example.sql'>

```sql

{% set relation_exists = (adapter.load_relation(ref('my_model')) is not none %}
{% if relation_exists %}
{{ log("my_model has already been built", info=true) }}
{% else %}
{{ log("my_model doesn't exist in the warehouse. Maybe it was dropped?", info=true) }}
{% endif %}

```

</File>


## get_columns_in_relation
__Args__:
Expand Down

0 comments on commit 9a96a89

Please sign in to comment.