Skip to content

Commit b165de1

Browse files
committed
Update test with schema pattern
1 parent c02a04e commit b165de1

File tree

5 files changed

+34
-3
lines changed

5 files changed

+34
-3
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
user_id,event
2+
5,play
3+
6,pause
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
user_id,event
2+
1,play
3+
2,pause
4+
3,play
5+
4,pause
6+
5,play
7+
6,pause

integration_tests/dbt_project.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,7 @@ seeds:
4646
num_buckets: integer
4747
min_value: float
4848
max_value: float
49+
50+
sql:
51+
data_events_20180103:
52+
+schema: events

integration_tests/models/sql/schema.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ models:
5050
values:
5151
- '5'
5252

53-
- name: test_get_tables_by_prefix_and_union
53+
- name: test_get_relations_by_prefix_and_union
5454
columns:
5555
- name: event
5656
tests:
@@ -117,3 +117,8 @@ models:
117117
tests:
118118
- dbt_utils.equality:
119119
compare_model: ref('data_union_expected')
120+
121+
- name: test_get_relations_by_pattern
122+
tests:
123+
- dbt_utils.equality:
124+
compare_model: ref('data_union_events_expected')
Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
{{ config(materialized = 'table') }}
22

3-
{% set relations = dbt_utils.get_relations_by_pattern(target.schema, 'data_events_%') %}
4-
{{ dbt_utils.union_relations(relations) }}
3+
{% set relations = dbt_utils.get_relations_by_pattern(target.schema ~ '%', 'data_events_%') %}
4+
5+
with unioned as (
6+
7+
{{ dbt_utils.union_relations(relations) }}
8+
9+
)
10+
11+
select
12+
13+
user_id,
14+
event
15+
16+
from unioned

0 commit comments

Comments
 (0)