Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test_cloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on: # yamllint disable-line rule:truthy
- '*_cloud'
workflow_dispatch:
schedule:
- cron: '0 2 * * *' # Nightly run at 2:00 AM UTC
- cron: '0 2 * * *' # Nightly run at 2:00 AM UTC

jobs:
cloud_smt_tests:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### Release [1.9.5], 2025-XX-XX

#### Improvements
* Allow db_engine = 'Shared' in supports_atomic_exchange() ([#543](https://github.com/ClickHouse/dbt-clickhouse/pull/543)).


### Release [1.9.4], 2025-10-08

#### Improvements
Expand Down
4 changes: 2 additions & 2 deletions dbt/adapters/clickhouse/dbclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
)
from dbt.adapters.clickhouse.logger import logger
from dbt.adapters.clickhouse.query import quote_identifier
from dbt.adapters.clickhouse.util import compare_versions
from dbt.adapters.clickhouse.util import compare_versions, engine_can_atomic_exchange
from dbt.adapters.exceptions import FailedToConnectError
from dbt_common.exceptions import DbtConfigError, DbtDatabaseError

Expand Down Expand Up @@ -224,7 +224,7 @@ def _ensure_database(self, database_engine, cluster_name) -> None:
def _check_atomic_exchange(self) -> bool:
try:
db_engine = self.command('SELECT engine FROM system.databases WHERE name = database()')
if db_engine not in ('Atomic', 'Replicated'):
if not engine_can_atomic_exchange(db_engine):
return False
create_cmd = (
'CREATE TABLE IF NOT EXISTS {} (test String) ENGINE MergeTree() ORDER BY tuple()'
Expand Down
6 changes: 3 additions & 3 deletions dbt/adapters/clickhouse/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from dbt.adapters.clickhouse.logger import logger
from dbt.adapters.clickhouse.query import quote_identifier
from dbt.adapters.clickhouse.relation import ClickHouseRelation, ClickHouseRelationType
from dbt.adapters.clickhouse.util import compare_versions
from dbt.adapters.clickhouse.util import compare_versions, engine_can_atomic_exchange
from dbt.adapters.contracts.relation import Path, RelationConfig
from dbt.adapters.events.types import ConstraintNotSupported
from dbt.adapters.sql import SQLAdapter
Expand Down Expand Up @@ -166,7 +166,7 @@ def can_exchange(self, schema: str, rel_type: str) -> bool:
if rel_type != 'table' or not schema or not self.supports_atomic_exchange():
return False
ch_db = self.get_ch_database(schema)
return ch_db and ch_db.engine in ('Atomic', 'Replicated', 'Shared')
return ch_db and engine_can_atomic_exchange(ch_db.engine)

@available.parse_none
def should_on_cluster(self, materialized: str = '', engine: str = '') -> bool:
Expand Down Expand Up @@ -341,7 +341,7 @@ def list_relations_without_caching(
can_exchange = (
conn_supports_exchange
and rel_type == ClickHouseRelationType.Table
and db_engine in ('Atomic', 'Replicated', 'Shared')
and engine_can_atomic_exchange(db_engine)
)
can_on_cluster = (on_cluster >= 1) and db_engine != 'Replicated'

Expand Down
4 changes: 4 additions & 0 deletions dbt/adapters/clickhouse/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ def hide_stack_trace(ex: Exception) -> str:

err_msg = str(ex).split("Stack trace")[0].strip()
return err_msg


def engine_can_atomic_exchange(engine: str) -> bool:
return engine in ['Atomic', 'Replicated', 'Shared']