Skip to content

Commit

Permalink
On cluster sync cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
genzgd committed Nov 28, 2023
1 parent 9997b82 commit 3fec9a4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ jobs:
- name: Run Native tests
env:
DBT_CH_TEST_PORT: 9000
DBT_CH_TEST_CLUSTER: test_shard
run: |
PYTHONPATH="${PYTHONPATH}:dbt"
pytest tests
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
### Release [1.5.2], 2023-11-28
#### Bug Fix
- The `ON CLUSTER` clause was in the incorrect place for legacy incremental materializations. This has been fixed. Thanks to
[Steven Reitsma](https://github.com/StevenReitsma) for the fix!
- The `ON CLUSTER` DDL for drop tables did not include a SYNC modifier, which might be the cause of some "table already exists"
errors

### Release [1.5.1], 2023-11-27
#### Bug Fix
- Fix table materialization for compatibility with SQLFluff. Thanks to [Kristof Szaloki](https://github.com/kris947) for the PR!
Expand Down
2 changes: 1 addition & 1 deletion dbt/adapters/clickhouse/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = '1.5.1'
version = '1.5.2'
2 changes: 1 addition & 1 deletion dbt/include/clickhouse/macros/adapters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
{% macro clickhouse__drop_relation(relation, obj_type='table') -%}
{% call statement('drop_relation', auto_begin=False) -%}
{# drop relation on cluster by default if cluster is set #}
drop {{ obj_type }} if exists {{ relation }} {{ on_cluster_clause(relation.without_identifier())}}
drop {{ obj_type }} if exists {{ relation }} {{ on_cluster_clause(relation.without_identifier(), True)}}
{%- endcall %}
{% endmacro %}

Expand Down
5 changes: 4 additions & 1 deletion dbt/include/clickhouse/macros/materializations/table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,14 @@
{%- endif %}
{%- endmacro -%}

{% macro on_cluster_clause(relation) %}
{% macro on_cluster_clause(relation, force_sync) %}
{% set active_cluster = adapter.get_clickhouse_cluster_name() %}
{%- if active_cluster is not none and relation.should_on_cluster %}
{# Add trailing whitespace to avoid problems when this clause is not last #}
ON CLUSTER {{ active_cluster + ' ' }}
{%- if force_sync %}
SYNC
{%- endif %}
{%- endif %}
{%- endmacro -%}

Expand Down

0 comments on commit 3fec9a4

Please sign in to comment.