88import pytest
99from dbt .adapters .clickhouse .query import quote_identifier
1010from dbt .tests .util import check_relation_types , run_dbt
11+ from dbt .tests .fixtures .project import TestProjInfo
1112
1213PEOPLE_SEED_CSV = """
1314id,name,age,department
@@ -193,14 +194,14 @@ def test_disabled_catchup(self, project):
193194"""
194195
195196
196- def query_table_type (project , schema , table ) :
197+ def query_table_type (project : TestProjInfo , schema : str , table : str ) -> str :
197198 table_type = project .run_sql (
198199 f"""
199200 select engine from system.tables where database = '{ schema } ' and name = '{ table } '
200201 """ ,
201202 fetch = "all" ,
202203 )
203- return table_type [0 ][0 ] if len (table_type ) > 0 else None
204+ return table_type [0 ][0 ] if len (table_type ) > 0 else ''
204205
205206
206207class TestUpdateMV :
@@ -287,7 +288,7 @@ def test_mv_is_dropped_on_full_refresh(self, project):
287288 assert len (results ) == 2 # will include also a view for the other test.
288289
289290 # Verify both tables were created correctly
290- assert query_table_type (project , schema_unquoted , 'hackers_mv' ) == "MergeTree"
291+ assert query_table_type (project , schema_unquoted , 'hackers_mv' ). endswith ( "MergeTree" )
291292 assert query_table_type (project , schema_unquoted , 'hackers_mv_mv' ) == "MaterializedView"
292293
293294 # Step 3: Change model to view materialization and run with full refresh
@@ -300,7 +301,7 @@ def test_mv_is_dropped_on_full_refresh(self, project):
300301 # Step 4: Assert that target table is now a view and internal MV no longer exists
301302 assert query_table_type (project , schema_unquoted , 'hackers_mv' ) == "View"
302303 # Verify that the internal materialized view (_mv) no longer exists
303- assert query_table_type (project , schema_unquoted , 'hackers_mv_mv' ) is None
304+ assert not query_table_type (project , schema_unquoted , 'hackers_mv_mv' )
304305
305306 def test_view_full_refresh_does_not_affect_existing_mv_with_mv_suffix (self , project ):
306307 """
@@ -321,7 +322,7 @@ def test_view_full_refresh_does_not_affect_existing_mv_with_mv_suffix(self, proj
321322
322323 # Verify both models were created correctly
323324 assert query_table_type (project , schema_unquoted , 'hackers' ) == "View"
324- assert query_table_type (project , schema_unquoted , 'hackers_mv' ) == "MergeTree"
325+ assert query_table_type (project , schema_unquoted , 'hackers_mv' ). endswith ( "MergeTree" )
325326 assert query_table_type (project , schema_unquoted , 'hackers_mv_mv' ) == "MaterializedView"
326327
327328 # Verify data is present in both
@@ -341,7 +342,7 @@ def test_view_full_refresh_does_not_affect_existing_mv_with_mv_suffix(self, proj
341342 assert result [0 ][0 ] == 3
342343
343344 # Verify that hackers_mv and hackers_mv_mv are still present and working
344- assert query_table_type (project , schema_unquoted , 'hackers_mv' ) == "MergeTree"
345+ assert query_table_type (project , schema_unquoted , 'hackers_mv' ). endswith ( "MergeTree" )
345346 assert query_table_type (project , schema_unquoted , 'hackers_mv_mv' ) == "MaterializedView"
346347
347348 result = project .run_sql (f"select count(*) from { schema_unquoted } .hackers_mv" , fetch = "all" )
0 commit comments