Skip to content

Commit

Permalink
feat: add TTL support
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian2012 committed Mar 4, 2024
1 parent d811e90 commit 07ba91a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions dbt/adapters/clickhouse/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class ClickHouseConfig(AdapterConfig):
order_by: Optional[Union[List[str], str]] = 'tuple()'
partition_by: Optional[Union[List[str], str]] = None
sharding_key: Optional[Union[List[str], str]] = 'rand()'
ttl: Optional[Union[List[str], str]] = None


class ClickHouseAdapter(SQLAdapter):
Expand Down
7 changes: 7 additions & 0 deletions dbt/include/clickhouse/macros/materializations/table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@
{%- endif %}
{%- endmacro -%}

{% macro ttl_config(label) %}
{%- if config.get("ttl")%}
{{ label }} {{ config.get("ttl") }}
{%- endif %}
{%- endmacro -%}

{% 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 %}
Expand Down Expand Up @@ -170,6 +176,7 @@
{{ order_cols(label="order by") }}
{{ primary_key_clause(label="primary key") }}
{{ partition_cols(label="partition by") }}
{{ ttl_config(label="ttl")}}
{{ adapter.get_model_settings(model) }}

{%- if not has_contract %}
Expand Down

0 comments on commit 07ba91a

Please sign in to comment.