Skip to content

Commit

Permalink
Clean up quote values defaults (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
clausherther authored Dec 20, 2022
1 parent eea6908 commit 1651fce
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 48 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ Expect each column value to be in a given set.
tests:
- dbt_expectations.expect_column_values_to_be_in_set:
value_set: ['a','b','c']
quote_values: true # (Optional)
quote_values: true # (Optional. Default is 'true'.)
row_condition: "id is not null" # (Optional)
```

Expand Down Expand Up @@ -531,7 +531,7 @@ Expect each column value not to be in a given set.
tests:
- dbt_expectations.expect_column_values_to_not_be_in_set:
value_set: ['e','f','g']
quote_values: true # (Optional)
quote_values: true # (Optional. Default is 'true'.)
row_condition: "id is not null" # (Optional)
```

Expand Down Expand Up @@ -723,7 +723,7 @@ Expect the number of distinct column values to be equal to a given value.
tests:
- dbt_expectations.expect_column_distinct_count_to_equal:
value: 10
quote_values: false # (Optional. Default is 'false'.)
quote_values: true # (Optional. Default is 'true'.)
group_by: [group_id, other_group_id, ...] # (Optional)
row_condition: "id is not null" # (Optional)
```
Expand All @@ -738,7 +738,7 @@ Expect the number of distinct column values to be greater than a given value.
tests:
- dbt_expectations.expect_column_distinct_count_to_be_greater_than:
value: 10
quote_values: false # (Optional. Default is 'false'.)
quote_values: true # (Optional. Default is 'true'.)
group_by: [group_id, other_group_id, ...] # (Optional)
row_condition: "id is not null" # (Optional)
```
Expand All @@ -753,7 +753,7 @@ Expect the number of distinct column values to be less than a given value.
tests:
- dbt_expectations.expect_column_distinct_count_to_be_less_than:
value: 10
quote_values: false # (Optional. Default is 'false'.)
quote_values: true # (Optional. Default is 'true'.)
group_by: [group_id, other_group_id, ...] # (Optional)
row_condition: "id is not null" # (Optional)
```
Expand All @@ -768,7 +768,7 @@ Expect the set of distinct column values to be contained by a given set.
tests:
- dbt_expectations.expect_column_distinct_values_to_be_in_set:
value_set: ['a','b','c','d']
quote_values: false # (Optional. Default is 'false'.)
quote_values: true # (Optional. Default is 'true'.)
row_condition: "id is not null" # (Optional)
```

Expand All @@ -784,7 +784,7 @@ In contrast to `expect_column_values_to_be_in_set` this ensures not that all col
tests:
- dbt_expectations.expect_column_distinct_values_to_contain_set:
value_set: ['a','b']
quote_values: false # (Optional. Default is 'false'.)
quote_values: true # (Optional. Default is 'true'.)
row_condition: "id is not null" # (Optional)
```

Expand Down Expand Up @@ -951,7 +951,7 @@ tests:
- dbt_expectations.expect_column_most_common_value_to_be_in_set:
value_set: [0.5]
top_n: 1
quote_values: false # (Optional)
quote_values: true # (Optional. Default is 'true'.)
data_type: "decimal" # (Optional. Default is 'decimal')
strictly: false # (Optional. Default is 'false'. Adds an 'or equal to' to the comparison operator for min/max)
```
Expand Down
3 changes: 1 addition & 2 deletions integration_tests/models/schema_tests/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ models:
- dbt_expectations.expect_column_most_common_value_to_be_in_set:
value_set: [0.5]
top_n: 1
quote_values: false
- dbt_expectations.expect_column_values_to_be_increasing:
sort_column: col_numeric_a
strictly: false
Expand All @@ -357,13 +358,11 @@ models:
quote_values: true
- dbt_expectations.expect_column_distinct_values_to_equal_set:
value_set: ['a','b','c','c']
quote_values: true
- dbt_expectations.expect_column_distinct_values_to_be_in_set:
value_set: ['a','b','c','d']
quote_values: true
- dbt_expectations.expect_column_distinct_values_to_contain_set:
value_set: ['a','b']
quote_values: true
- dbt_expectations.expect_column_value_lengths_to_equal:
value: 1
- dbt_expectations.expect_column_values_to_have_consistent_casing
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{% test expect_column_distinct_count_to_be_greater_than(model,
column_name,
value,
quote_values=False,
group_by=None,
row_condition=None
) %}
column_name,
value,
group_by=None,
row_condition=None
) %}
{% set expression %}
count(distinct {{ column_name }}) > {{ value }}
{% endset %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{% test expect_column_distinct_count_to_be_less_than(model,
column_name,
value,
quote_values=False,
group_by=None,
row_condition=None
) %}
column_name,
value,
group_by=None,
row_condition=None
) %}
{% set expression %}
count(distinct {{ column_name }}) < {{ value }}
{% endset %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{% test expect_column_distinct_count_to_equal(model,
column_name,
value,
quote_values=False,
group_by=None,
row_condition=None
) %}
column_name,
value,
group_by=None,
row_condition=None
) %}
{% set expression %}
count(distinct {{ column_name }}) = {{ value }}
{% endset %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{% test expect_column_distinct_values_to_be_in_set(model, column_name,
value_set,
quote_values=False,
row_condition=None
) %}
{% test expect_column_distinct_values_to_be_in_set(model,
column_name,
value_set,
quote_values=True,
row_condition=None
) %}

with all_values as (

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
{% test expect_column_most_common_value_to_be_in_set(model, column_name,
value_set,
top_n,
quote_values=False,
data_type="decimal",
row_condition=None
) -%}
{{ adapter.dispatch('test_expect_column_most_common_value_to_be_in_set', 'dbt_expectations') (model, column_name, value_set, top_n, quote_values, data_type, row_condition) }}
{% test expect_column_most_common_value_to_be_in_set(model,
column_name,
value_set,
top_n,
quote_values=True,
data_type="decimal",
row_condition=None
) -%}

{{ adapter.dispatch('test_expect_column_most_common_value_to_be_in_set', 'dbt_expectations') (
model, column_name, value_set, top_n, quote_values, data_type, row_condition
) }}

{%- endtest %}

{% macro default__test_expect_column_most_common_value_to_be_in_set(model, column_name,
value_set,
top_n,
quote_values,
data_type,
row_condition
) %}
{% macro default__test_expect_column_most_common_value_to_be_in_set(model,
column_name,
value_set,
top_n,
quote_values,
data_type,
row_condition
) %}

with value_counts as (

Expand Down

0 comments on commit 1651fce

Please sign in to comment.