Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic error test, fix minor merge conflict #202

Merged
merged 1 commit into from
Oct 26, 2023
Merged
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
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