Skip to content

Commit 4859ddc

Browse files
authored
Merge pull request #543 from herbert-allium/patch-1
Allow db_engine = 'Shared' in supports_atomic_exchange()
2 parents 8ad472d + 48505c6 commit 4859ddc

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
### Release [1.9.6], 2025-11-03
2+
3+
#### Bugs
4+
* An important fix for cloud users using the `Shard Catalog` feature - Allow db_engine = 'Shared' in supports_atomic_exchange() ([#543](https://github.com/ClickHouse/dbt-clickhouse/pull/543)).
5+
6+
17
### Release [1.9.5], 2025-10-20
28

39
#### Bugs

dbt/adapters/clickhouse/dbclient.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
)
1313
from dbt.adapters.clickhouse.logger import logger
1414
from dbt.adapters.clickhouse.query import quote_identifier
15-
from dbt.adapters.clickhouse.util import compare_versions
15+
from dbt.adapters.clickhouse.util import compare_versions, engine_can_atomic_exchange
1616
from dbt.adapters.exceptions import FailedToConnectError
1717
from dbt_common.exceptions import DbtConfigError, DbtDatabaseError
1818

@@ -224,7 +224,7 @@ def _ensure_database(self, database_engine, cluster_name) -> None:
224224
def _check_atomic_exchange(self) -> bool:
225225
try:
226226
db_engine = self.command('SELECT engine FROM system.databases WHERE name = database()')
227-
if db_engine not in ('Atomic', 'Replicated'):
227+
if not engine_can_atomic_exchange(db_engine):
228228
return False
229229
create_cmd = (
230230
'CREATE TABLE IF NOT EXISTS {} (test String) ENGINE MergeTree() ORDER BY tuple()'

dbt/adapters/clickhouse/impl.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from dbt.adapters.clickhouse.logger import logger
3232
from dbt.adapters.clickhouse.query import quote_identifier
3333
from dbt.adapters.clickhouse.relation import ClickHouseRelation, ClickHouseRelationType
34-
from dbt.adapters.clickhouse.util import compare_versions
34+
from dbt.adapters.clickhouse.util import compare_versions, engine_can_atomic_exchange
3535
from dbt.adapters.contracts.relation import Path, RelationConfig
3636
from dbt.adapters.events.types import ConstraintNotSupported
3737
from dbt.adapters.sql import SQLAdapter
@@ -166,7 +166,7 @@ def can_exchange(self, schema: str, rel_type: str) -> bool:
166166
if rel_type != 'table' or not schema or not self.supports_atomic_exchange():
167167
return False
168168
ch_db = self.get_ch_database(schema)
169-
return ch_db and ch_db.engine in ('Atomic', 'Replicated', 'Shared')
169+
return ch_db and engine_can_atomic_exchange(ch_db.engine)
170170

171171
@available.parse_none
172172
def should_on_cluster(self, materialized: str = '', engine: str = '') -> bool:
@@ -341,7 +341,7 @@ def list_relations_without_caching(
341341
can_exchange = (
342342
conn_supports_exchange
343343
and rel_type == ClickHouseRelationType.Table
344-
and db_engine in ('Atomic', 'Replicated', 'Shared')
344+
and engine_can_atomic_exchange(db_engine)
345345
)
346346
can_on_cluster = (on_cluster >= 1) and db_engine != 'Replicated'
347347

dbt/adapters/clickhouse/util.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ def hide_stack_trace(ex: Exception) -> str:
2222

2323
err_msg = str(ex).split("Stack trace")[0].strip()
2424
return err_msg
25+
26+
27+
def engine_can_atomic_exchange(engine: str) -> bool:
28+
return engine in ['Atomic', 'Replicated', 'Shared']

0 commit comments

Comments
 (0)