From b09ed0edb866b0ec11a8f0b6bc2427cc3e2f5572 Mon Sep 17 00:00:00 2001 From: Matt Shaver <60105315+matthewshaver@users.noreply.github.com> Date: Fri, 26 Apr 2024 20:38:34 -0400 Subject: [PATCH] Clarifying BigQuery unit test (#5367) ## What are you changing in this pull request and why? Closes https://github.com/dbt-labs/docs.getdbt.com/issues/5331 Closes https://github.com/dbt-labs/docs.getdbt.com/issues/5307 ## Checklist - [x] Review the [Content style guide](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/content-style-guide.md) so my content adheres to these guidelines. - [x] For [docs versioning](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/single-sourcing-content.md#about-versioning), review how to [version a whole page](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/single-sourcing-content.md#adding-a-new-version) and [version a block of content](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/single-sourcing-content.md#versioning-blocks-of-content). - [x] Add a checklist item for anything that needs to happen before this PR is merged, such as "needs technical review" or "change base branch." --------- Co-authored-by: Leona B. Campbell <3880403+runleonarun@users.noreply.github.com> --- website/docs/docs/build/unit-tests.md | 3 ++- website/docs/reference/resource-properties/data-types.md | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/website/docs/docs/build/unit-tests.md b/website/docs/docs/build/unit-tests.md index 7156ff3bc48..9b0c4b83575 100644 --- a/website/docs/docs/build/unit-tests.md +++ b/website/docs/docs/build/unit-tests.md @@ -22,8 +22,9 @@ Now, we are introducing a new type of test to dbt - unit tests. In software prog ## Before you begin - We currently only support unit testing SQL models. -- We currently don't support unit testing models that use recursive SQL. - We currently only support adding unit tests to models in your _current_ project. +- We currently *don't* support unit testing models that use recursive SQL. +- You must specify all fields in a BigQuery STRUCT in a unit test. You cannot use only a subset of fields in a STRUCT. - If your model has multiple versions, by default the unit test will run on *all* versions of your model. Read [unit testing versioned models](#unit-testing-versioned-models) for more information. - Unit tests must be defined in a YML file in your `models/` directory. diff --git a/website/docs/reference/resource-properties/data-types.md b/website/docs/reference/resource-properties/data-types.md index 1adc4e3f502..6cea501208d 100644 --- a/website/docs/reference/resource-properties/data-types.md +++ b/website/docs/reference/resource-properties/data-types.md @@ -64,6 +64,9 @@ unit_tests: struct_field: 'struct("Isha" as name, 22 as age)' struct_of_struct_field: 'struct(struct(1 as id, "blue" as color) as my_struct)' struct_array_field: ['struct(st_geogpoint(75, 45) as my_point)', 'struct(st_geogpoint(75, 35) as my_point)'] + # Make sure to include all the fields in a BigQuery `struct` within the unit test. + # It's not currently possible to use only a subset of columns in a 'struct' + ```