Skip to content

Commit

Permalink
Add basic error test, fix minor merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
genzgd committed Oct 26, 2023
1 parent b79669a commit 2f40672
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dbt/adapters/clickhouse/dbclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
30 changes: 30 additions & 0 deletions tests/integration/adapter/test_errors.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2f40672

Please sign in to comment.