forked from dbt-labs/dbt-project-evaluator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fct_test_directories.sql
85 lines (61 loc) · 1.79 KB
/
fct_test_directories.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
with
resources as (
select * from {{ ref('int_all_graph_resources') }}
),
relationships as (
select * from {{ ref('int_direct_relationships') }}
),
models_per_test as (
select
resource_name as test_name,
resource_id as test_id,
direct_parent_id as parent_model_id
from relationships
where resource_type = 'test'
and is_primary_test_relationship
),
model_file_paths as (
select
resources.resource_id as model_id,
resources.resource_name as model_name,
resources.directory_path as model_directory_path,
models_per_test.test_id,
models_per_test.parent_model_id
from resources
inner join models_per_test
on models_per_test.parent_model_id = resources.resource_id
where resource_type = 'model'
),
test_file_paths as (
select
resource_id as test_id,
resource_name as test_name,
file_name as test_yml_name,
directory_path as test_yml_directory_path
from resources
where resource_type = 'test'
),
all_file_paths as (
select
test_file_paths.test_id,
test_file_paths.test_name,
test_file_paths.test_yml_directory_path,
test_file_paths.test_yml_name,
model_file_paths.model_id,
model_file_paths.model_name,
model_file_paths.model_directory_path
from model_file_paths
inner join test_file_paths
on model_file_paths.test_id = test_file_paths.test_id
),
different_directories as (
select
test_name,
model_name,
test_yml_directory_path as current_test_directory,
model_directory_path as change_test_directory_to
from all_file_paths
where model_directory_path != test_yml_directory_path
)
select * from different_directories
{{ filter_exceptions(this) }}