Skip to content

Commit 2cfe8c0

Browse files
authored
Add bool or cross db (#504)
* Create bool_or cross-db func * Forgot a comma * Update CHANGELOG.md
1 parent 5243381 commit 2cfe8c0

File tree

6 files changed

+47
-0
lines changed

6 files changed

+47
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## New features
44
- A cross-database implementation of `any_value()` ([#497](https://github.com/dbt-labs/dbt-utils/issues/497), [#501](https://github.com/dbt-labs/dbt-utils/pull/501))
5+
- A cross-database implementation of `bool_or()` ([#504](https://github.com/dbt-labs/dbt-utils/pull/504))
56

67
## Under the hood
78
- also ignore `dbt_packages/` directory [#463](https://github.com/dbt-labs/dbt-utils/pull/463)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
key,val1,val2
2+
abc,1,1
3+
abc,1,0
4+
def,1,0
5+
hij,1,1
6+
hij,1,
7+
klm,1,0
8+
klm,1,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
key,value
2+
abc,true
3+
def,false
4+
hij,true
5+
klm,false

integration_tests/models/cross_db_utils/schema.yml

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ models:
66
- dbt_utils.equality:
77
compare_model: ref('data_any_value_expected')
88

9+
- name: test_bool_or
10+
tests:
11+
- dbt_utils.equality:
12+
compare_model: ref('data_bool_or_expected')
913

1014
- name: test_concat
1115
tests:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
select
2+
key,
3+
{{ dbt_utils.bool_or('val1 = val2') }} as value
4+
from {{ ref('data_bool_or' )}}
5+
group by key

macros/cross_db_utils/bool_or.sql

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{% macro bool_or(expression) -%}
2+
{{ return(adapter.dispatch('bool_or', 'dbt_utils') (expression)) }}
3+
{% endmacro %}
4+
5+
6+
{% macro default__bool_or(expression) -%}
7+
8+
bool_or({{ expression }})
9+
10+
{%- endmacro %}
11+
12+
13+
{% macro snowflake__bool_or(expression) -%}
14+
15+
boolor_agg({{ expression }})
16+
17+
{%- endmacro %}
18+
19+
20+
{% macro bigquery__bool_or(expression) -%}
21+
22+
logical_or({{ expression }})
23+
24+
{%- endmacro %}

0 commit comments

Comments
 (0)