Skip to content

Commit

Permalink
Add ability to run dbt tests with ClickHouse, passing TestResultData …
Browse files Browse the repository at this point in the history
…validation (#18)
  • Loading branch information
artamoshin authored Oct 1, 2021
1 parent 0bc8826 commit 07b94e2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pip install dbt-clickhouse
- [x] Seeds
- [x] Sources
- [x] Docs generate
- [x] Tests
- [x] Snapshots (experimental)
- [ ] Ephemeral materialization

Expand Down
12 changes: 12 additions & 0 deletions dbt/include/clickhouse/macros/materializations/test.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% macro clickhouse__get_test_sql(main_sql, fail_calc, warn_if, error_if, limit) -%}
select
{{ fail_calc }} as failures,
case when {{ fail_calc }} {{ warn_if }}
then 'true' else 'false' end as should_warn,
case when {{ fail_calc }} {{ error_if }}
then 'true' else 'false' end as should_error
from (
{{ main_sql }}
{{ "limit " ~ limit if limit != none }}
) dbt_internal_test
{%- endmacro %}
6 changes: 1 addition & 5 deletions test/integration/clickhouse.dbtspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,4 @@ sequences:
test_dbt_snapshot_strategy_timestamp: snapshot_strategy_timestamp
test_dbt_snapshot_strategy_check_cols: snapshot_strategy_check_cols
test_dbt_data_test: data_test
# Version 0.20.0 validates schema a TestResultData
# https://github.com/dbt-labs/dbt/blob/e3cb050bbc8faa763f325c89247d9da4d0984724/core/dbt/task/test.py#L34
# But ClickHouse does not have a boolean type (instead of uint8)
# The test works, but we are skipping it
# test_dbt_schema_test: schema_test
test_dbt_schema_test: schema_test

0 comments on commit 07b94e2

Please sign in to comment.