Setting descriptions for BigQuery tables from DBT

We are looking to set BigQuery table descriptions. We do not DBT Cloud, and we mainly care about setting the descriptions for folks to see in the BigQuery UI itself (not DBT docs).

The query below works just fine in the BigQuery UI for updating the table description.

ALTER TABLE IF EXISTS our_dataset.our_model SET OPTIONS(description="Price per unit").

How can we save this / fit this query into our DBT project? It doesn’t seem like we can add this to the top or bottom of the .sql models files. Also we cannot simply save this in its own model as we get the error Syntax error: Expected "(" or keyword SELECT or keyword WITH but got keyword ALTER... when we do this.

Hi, I believe you are looking for the “persist_docs” option. This can be added to the dbt_project.yml for your dbt project. We use this and it adds in the description in an OPTIONS block to the queries that are run during the dbt run command. Check out: persist_docs | dbt Docs

3 Likes

Fantastic, yes this worked perfectly. Thank you!