forked from dremio/dbt-dremio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_exact_search.py
More file actions
121 lines (87 loc) · 4.16 KB
/
test_exact_search.py
File metadata and controls
121 lines (87 loc) · 4.16 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import pytest
from dbt.tests.util import run_dbt, get_connection
from tests.utils.util import relation_from_name
from tests.fixtures.profiles import unique_schema, dbt_profile_data
class TestExactSearchEnabled:
@pytest.fixture(scope="class")
def models(self):
return {
"create_table.sql": """
{{ config(
materialized='table',
root_path='schema') }}
select 1 as ilike
"""
}
@pytest.fixture(scope="class", autouse=True)
def setup_table(self, project):
run_dbt(["run", "--full-refresh",])
def test_exact_match_succeeds(self, project):
schema = project.test_schema
run_dbt(["run", "--vars", '{"dremio:exact_search_enabled": true}'])
adapter = project.adapter
with get_connection(project.adapter):
exists = adapter.check_schema_exists(project.database, schema)
assert exists
def test_exact_match_fails_on_case_mismatch(self, project):
schema = project.test_schema
run_dbt(["run", "--vars", '{"dremio:exact_search_enabled": true}'])
adapter = project.adapter
with get_connection(project.adapter):
exists = adapter.check_schema_exists(project.database, schema.upper())
assert not exists
def test_ilike_match_succeeds(self, project):
schema = project.test_schema
run_dbt(["run", "--vars", '{"dremio:exact_search_enabled": false}'])
adapter = project.adapter
with get_connection(project.adapter):
exists = adapter.check_schema_exists(project.database, schema.upper())
assert exists
def test_exact_match_get_columns(self, project):
schema = "schema.create_table"
run_dbt(["run", "--vars", '{"dremio:exact_search_enabled": true}'])
table_relation = relation_from_name(
project.adapter, schema)
with get_connection(project.adapter):
columns = project.adapter.get_columns_in_relation(table_relation)
assert len(columns) == 1
def test_ilike_get_columns(self, project):
schema = "schema.create_table"
run_dbt(["run", "--vars", '{"dremio:exact_search_enabled": false}'])
table_relation = relation_from_name(
project.adapter, schema)
with get_connection(project.adapter):
columns = project.adapter.get_columns_in_relation(table_relation)
assert len(columns) == 1
def test_exact_match_succeeds_list_relations_without_caching(self, project):
run_dbt(["run", "--vars", '{"dremio:exact_search_enabled": true}'])
adapter = project.adapter
table_relation = relation_from_name(
project.adapter, "schema.create_table")
with get_connection(adapter):
columns = adapter.list_relations_without_caching(table_relation)
assert len(columns) == 1
def test_exact_match_fails_list_relations_without_caching(self, project):
run_dbt(["run", "--vars", '{"dremio:exact_search_enabled": true}'])
adapter = project.adapter
table_relation = relation_from_name(
project.adapter, "SCHEMA.create_table")
with get_connection(adapter):
columns = adapter.list_relations_without_caching(table_relation)
assert len(columns) == 0
def test_ilike_list_relations_without_caching(self, project):
run_dbt(["run", "--vars", '{"dremio:exact_search_enabled": false}'])
adapter = project.adapter
table_relation = relation_from_name(
project.adapter, "schema.create_table")
with get_connection(adapter):
columns = adapter.list_relations_without_caching(table_relation)
assert len(columns) == 1
def test_ilike_case_sensitive_list_relations_without_caching(self, project):
run_dbt(["run", "--vars", '{"dremio:exact_search_enabled": false}'])
adapter = project.adapter
table_relation = relation_from_name(
project.adapter, "SCHEMA.create_table")
with get_connection(adapter):
columns = adapter.list_relations_without_caching(table_relation)
assert len(columns) == 1