Skip to content

Commit

Permalink
Limit columns selected in expression_is_true if failures not stored. (
Browse files Browse the repository at this point in the history
#686)

* Update from template to dbt copyright (#647)

* Update from template to dbt copyright

I want to give proper attribution and licensing to code from dbt_utils that I'm using, so made this fix. Hope it's ok.

* Update LICENSE

* Limit columns selected in `expression_is_true` if failures not stored.

Fixes #683

Co-authored-by: Maayan Salom <[email protected]>
Co-authored-by: Joel Labes <[email protected]>
  • Loading branch information
3 people committed Sep 28, 2022
1 parent d99da52 commit c15d55e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
## New features
- Implemented an optional `group_by_columns` argument across many of the generic testing macros to test for properties that only pertain to group-level or are can be more rigorously conducted at the group level. Property available in `recency`, `at_least_one`, `equal_row_count`, `fewer_rows_than`, `not_constant`, `not_null_proportion`, and `sequential` tests [#633](https://github.com/dbt-labs/dbt-utils/pull/633)
- New feature to omit the `source_column_name` column on the `union_relations` macro ([#331](https://github.com/dbt-labs/dbt-utils/issues/331), [#624](https://github.com/dbt-labs/dbt-utils/pull/624))
- New feature to select fewer columns in `expression_is_true` ([#683](https://github.com/dbt-labs/dbt-utils/issues/683), [#686](https://github.com/dbt-labs/dbt-utils/pull/686))
- Add `not_empty_string` generic test that asserts column values are not an empty string. ([#632](https://github.com/dbt-labs/dbt-utils/issues/632), [#634](https://github.com/dbt-labs/dbt-utils/pull/634))

## Under the hood
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2022 dbt Labs, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
4 changes: 3 additions & 1 deletion macros/generic_tests/expression_is_true.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@

{% macro default__test_expression_is_true(model, expression, column_name, condition) %}

{% set column_list = '*' if should_store_failures() else "1" %}

with meet_condition as (
select * from {{ model }} where {{ condition }}
)

select
*
{{ column_list }}
from meet_condition
{% if column_name is none %}
where not({{ expression }})
Expand Down

0 comments on commit c15d55e

Please sign in to comment.