Skip to content

Commit d97920d

Browse files
committed
Adapt the unit tests to the changes
Signed-off-by: Anton Zhyltsou <[email protected]>
1 parent c11b93f commit d97920d

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

tests/unit/macros/adapters/test_metadata_macros.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ def test_get_uc_tables_sql_with_identifier(self, template_bundle, relation):
137137
table_name,
138138
if(table_type IN ('EXTERNAL', 'MANAGED', 'MANAGED_SHALLOW_CLONE', 'EXTERNAL_SHALLOW_CLONE'), 'table', lower(table_type)) AS table_type,
139139
lower(data_source_format) AS file_format,
140-
table_owner
140+
table_owner,
141+
if(table_type IN ('EXTERNAL', 'MANAGED', 'MANAGED_SHALLOW_CLONE', 'EXTERNAL_SHALLOW_CLONE'), lower(table_type), null) AS databricks_table_type
141142
FROM `system`.`information_schema`.`tables`
142143
WHERE table_catalog = 'some_database'
143144
AND table_schema = 'some_schema'
@@ -155,9 +156,10 @@ def test_get_uc_tables_sql_without_identifier(self, template_bundle, mock_schema
155156
table_name,
156157
if(table_type IN ('EXTERNAL', 'MANAGED', 'MANAGED_SHALLOW_CLONE', 'EXTERNAL_SHALLOW_CLONE'), 'table', lower(table_type)) AS table_type,
157158
lower(data_source_format) AS file_format,
158-
table_owner
159+
table_owner,
160+
if(table_type IN ('EXTERNAL', 'MANAGED', 'MANAGED_SHALLOW_CLONE', 'EXTERNAL_SHALLOW_CLONE'), lower(table_type), null) AS databricks_table_type
159161
FROM `system`.`information_schema`.`tables`
160-
WHERE table_catalog = 'test_db'
162+
WHERE table_catalog = 'test_db'
161163
AND table_schema = 'test_schema'
162164
""" # noqa
163165
self.assert_sql_equal(result, expected_sql)
@@ -176,9 +178,10 @@ def test_case_sensitivity(self, template_bundle):
176178
table_name,
177179
if(table_type IN ('EXTERNAL', 'MANAGED', 'MANAGED_SHALLOW_CLONE', 'EXTERNAL_SHALLOW_CLONE'), 'table', lower(table_type)) AS table_type,
178180
lower(data_source_format) AS file_format,
179-
table_owner
181+
table_owner,
182+
if(table_type IN ('EXTERNAL', 'MANAGED', 'MANAGED_SHALLOW_CLONE', 'EXTERNAL_SHALLOW_CLONE'), lower(table_type), null) AS databricks_table_type
180183
FROM `system`.`information_schema`.`tables`
181-
WHERE table_catalog = 'test_db'
184+
WHERE table_catalog = 'test_db'
182185
AND table_schema = 'test_schema'
183186
AND table_name = 'test_table'
184187
""" # noqa

tests/unit/macros/materializations/test_clone_macros.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def test_create_or_replace_clone(self, template_bundle, s_relation):
7373
def test_create_or_replace_clone_external(self, template_bundle, catalog_relation, s_relation):
7474
sql = self.render_clone_macro(
7575
template_bundle,
76-
"databricks__create_or_replace_clone_external",
76+
"create_or_replace_clone_external",
7777
s_relation,
7878
template_bundle.relation,
7979
)

tests/unit/test_adapter.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,15 @@
1313
from dbt.adapters.databricks.credentials import (
1414
CATALOG_KEY_IN_SESSION_PROPERTIES,
1515
)
16-
from dbt.adapters.databricks.impl import get_identifier_list_string
17-
from dbt.adapters.databricks.relation import DatabricksRelation, DatabricksRelationType
16+
from dbt.adapters.databricks.impl import (
17+
DatabricksRelationInfo,
18+
get_identifier_list_string,
19+
)
20+
from dbt.adapters.databricks.relation import (
21+
DatabricksRelation,
22+
DatabricksRelationType,
23+
DatabricksTableType,
24+
)
1825
from dbt.adapters.databricks.utils import check_not_found_error
1926
from dbt.config import RuntimeConfig
2027
from tests.unit.utils import config_from_parts_or_dicts
@@ -356,7 +363,9 @@ def test_list_relations_without_caching__no_relations(self, _):
356363
@patch("dbt.adapters.databricks.api_client.DatabricksApiClient.create")
357364
def test_list_relations_without_caching__some_relations(self, _):
358365
with patch.object(DatabricksAdapter, "get_relations_without_caching") as mocked:
359-
mocked.return_value = [("name", "table", "hudi", "owner")]
366+
mocked.return_value = [
367+
DatabricksRelationInfo("name", "table", "hudi", "owner", "external")
368+
]
360369
adapter = DatabricksAdapter(Mock(flags={}), get_context("spawn"))
361370
relations = adapter.list_relations("database", "schema")
362371
assert len(relations) == 1
@@ -365,13 +374,17 @@ def test_list_relations_without_caching__some_relations(self, _):
365374
assert relation.database == "database"
366375
assert relation.schema == "schema"
367376
assert relation.type == DatabricksRelationType.Table
377+
assert relation.databricks_table_type == DatabricksTableType.External
368378
assert relation.owner == "owner"
379+
assert relation.is_external_table
369380
assert relation.is_hudi
370381

371382
@patch("dbt.adapters.databricks.api_client.DatabricksApiClient.create")
372383
def test_list_relations_without_caching__hive_relation(self, _):
373384
with patch.object(DatabricksAdapter, "get_relations_without_caching") as mocked:
374-
mocked.return_value = [("name", "table", None, None)]
385+
mocked.return_value = [
386+
DatabricksRelationInfo("name", "table", None, None, None)
387+
]
375388
adapter = DatabricksAdapter(Mock(flags={}), get_context("spawn"))
376389
relations = adapter.list_relations("database", "schema")
377390
assert len(relations) == 1

0 commit comments

Comments
 (0)