Skip to content

Commit

Permalink
Merge branch 'current' into delimiter-adding
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewshaver authored Oct 12, 2023
2 parents 462f4c7 + 0eef471 commit 211a847
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 2 deletions.
4 changes: 4 additions & 0 deletions website/dbt-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ exports.versions = [
]

exports.versionedPages = [
{
"page": "reference/resource-configs/store_failures_as",
"firstVersion": "1.7",
},
{
"page": "docs/build/build-metrics-intro",
"firstVersion": "1.6",
Expand Down
67 changes: 67 additions & 0 deletions website/docs/docs/build/metricflow-time-spine.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ To create this table, you need to create a model in your dbt project called `met

<File name='metricflow_time_spine.sql'>

<VersionBlock lastVersion="1.6">

```sql
{{
config(
Expand All @@ -38,8 +40,44 @@ final as (

select * from final
```

</VersionBlock>

<VersionBlock firstVersion="1.7">

```sql
{{
config(
materialized = 'table',
)
}}

with days as (

{{
dbt.date_spine(
'day',
"to_date('01/01/2000','mm/dd/yyyy')",
"to_date('01/01/2027','mm/dd/yyyy')"
)
}}

),

final as (
select cast(date_day as date) as date_day
from days
)

select * from final
```

</VersionBlock>

</File>

<VersionBlock lastVersion="1.6">

```sql
-- filename: metricflow_time_spine.sql
-- BigQuery supports DATE() instead of TO_DATE(). Use this model if you're using BigQuery
Expand All @@ -61,4 +99,33 @@ final as (
select *
from final
```

</VersionBlock>

<VersionBlock firstVersion="1.7">

```sql
-- filename: metricflow_time_spine.sql
-- BigQuery supports DATE() instead of TO_DATE(). Use this model if you're using BigQuery
{{config(materialized='table')}}
with days as (
{{dbt.date_spine(
'day',
"DATE(2000,01,01)",
"DATE(2030,01,01)"
)
}}
),

final as (
select cast(date_day as date) as date_day
from days
)

select *
from final
```

</VersionBlock>

You only need to include the `date_day` column in the table. MetricFlow can handle broader levels of detail, but it doesn't currently support finer grains.
2 changes: 1 addition & 1 deletion website/docs/docs/build/tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ where {{ column_name }} is null

## Storing test failures

Normally, a test query will calculate failures as part of its execution. If you set the optional `--store-failures` flag or [`store_failures` config](/reference/resource-configs/store_failures), dbt will first save the results of a test query to a table in the database, and then query that table to calculate the number of failures.
Normally, a test query will calculate failures as part of its execution. If you set the optional `--store-failures` flag, the [`store_failures`](/reference/resource-configs/store_failures), or the [`store_failures_as`](/reference/resource-configs/store_failures_as) configs, dbt will first save the results of a test query to a table in the database, and then query that table to calculate the number of failures.

This workflow allows you to query and examine failing records much more quickly in development:

Expand Down
1 change: 1 addition & 0 deletions website/docs/reference/node-selection/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dbt's node selection syntax makes it possible to run only specific resources in
| [compile](/reference/commands/compile) | `--select`, `--exclude`, `--selector`, `--inline` |
| [freshness](/reference/commands/source) | `--select`, `--exclude`, `--selector` |
| [build](/reference/commands/build) | `--select`, `--exclude`, `--selector`, `--resource-type`, `--defer` |
| [docs generate](/reference/commands/cmd-docs) | `--select` |

:::info Nodes and resources

Expand Down
2 changes: 1 addition & 1 deletion website/docs/reference/resource-configs/store_failures.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resource_types: [tests]
datatype: boolean
---

The configured test(s) will store their failures when `dbt test --store-failures` is invoked.
The configured test(s) will store their failures when `dbt test --store-failures` is invoked. If you set this configuration as `false` but [`store_failures_as`](/reference/resource-configs/store_failures_as) is configured, it will be overriden.

## Description
Optionally set a test to always or never store its failures in the database.
Expand Down
76 changes: 76 additions & 0 deletions website/docs/reference/resource-configs/store_failures_as.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
resource_types: [tests]
id: "store_failures_as"
---

For the `test` resource type, `store_failures_as` is an optional config that specifies how test failures should be stored in the database. If [`store_failures`](/reference/resource-configs/store_failures) is also configured, `store_failures_as` takes precedence.

The three supported values are:

- `ephemeral` &mdash; nothing stored in the database (default)
- `table` &mdash; test failures stored as a database table
- `view` &mdash; test failures stored as a database view

You can configure it in all the same places as `store_failures`, including singular tests (.sql files), generic tests (.yml files), and dbt_project.yml.

### Examples

#### Singular test

[Singular test](https://docs.getdbt.com/docs/build/tests#singular-tests) in `tests/singular/check_something.sql` file

```sql
{{ config(store_failures_as="table") }}

-- custom singular test
select 1 as id
where 1=0
```

#### Generic test

[Generic tests](https://docs.getdbt.com/docs/build/tests#generic-tests) in `models/_models.yml` file

```yaml
models:
- name: my_model
columns:
- name: id
tests:
- not_null:
config:
store_failures_as: view
- unique:
config:
store_failures_as: ephemeral
```
#### Project level
Config in `dbt_project.yml`

```yaml
name: "my_project"
version: "1.0.0"
config-version: 2
profile: "sandcastle"
tests:
my_project:
+store_failures_as: table
my_subfolder_1:
+store_failures_as: view
my_subfolder_2:
+store_failures_as: ephemeral
```

### "Clobbering" configs

As with most other configurations, `store_failures_as` is "clobbered" when applied hierarchically. Whenever a more specific value is available, it will completely replace the less specific value.

Additional resources:

- [Test configurations](/reference/test-configs#related-documentation)
- [Test-specific configurations](/reference/test-configs#test-specific-configurations)
- [Configuring directories of models in dbt_project.yml](/reference/model-configs#configuring-directories-of-models-in-dbt_projectyml)
- [Config inheritance](/reference/configs-and-properties#config-inheritance)
1 change: 1 addition & 0 deletions website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ const sidebarSettings = {
"reference/resource-configs/limit",
"reference/resource-configs/severity",
"reference/resource-configs/store_failures",
"reference/resource-configs/store_failures_as",
"reference/resource-configs/where",
],
},
Expand Down

0 comments on commit 211a847

Please sign in to comment.