diff --git a/dbt/adapters/clickhouse/dbclient.py b/dbt/adapters/clickhouse/dbclient.py index 320ea566..d029c16e 100644 --- a/dbt/adapters/clickhouse/dbclient.py +++ b/dbt/adapters/clickhouse/dbclient.py @@ -150,7 +150,11 @@ def _ensure_database(self, database_engine, cluster_name) -> None: db_exists = self.command(check_db) if not db_exists: engine_clause = f' ENGINE {database_engine} ' if database_engine else '' - cluster_clause = f' ON CLUSTER "{cluster_name}" ' if cluster_name is not None else '' + cluster_clause = ( + f' ON CLUSTER {cluster_name} ' + if cluster_name is not None and cluster_name.strip() != '' + else '' + ) self.command(f'CREATE DATABASE {self.database}{cluster_clause}{engine_clause}') db_exists = self.command(check_db) if not db_exists: diff --git a/tests/integration/adapter/test_errors.py b/tests/integration/adapter/test_errors.py new file mode 100644 index 00000000..cd841e83 --- /dev/null +++ b/tests/integration/adapter/test_errors.py @@ -0,0 +1,30 @@ +import pytest +from dbt.tests.util import run_dbt + +oom_table_sql = """ +SELECT a FROM system.numbers_mt GROUP BY repeat(toString(number), 100000) as a +""" + +schema_yaml = """ +version: 2 + +models: + - name: oom_table + description: Table that generates OOM + config: + materialized: table + order_by: a +""" + + +class TestOOMError: + @pytest.fixture(scope="class") + def models(self): + return { + "schema.yml": schema_yaml, + "oom_table.sql": oom_table_sql, + } + + def test_oom(self, project): + res = run_dbt(["run"], expect_pass=False) + assert 'exceeded' in res.results[0].message