Skip to content

Commit

Permalink
feat: add list support to primary_key
Browse files Browse the repository at this point in the history
Signed-off-by: Lucas Fernando Cardoso Nunes <lucasfc.nunes@gmail.com>
  • Loading branch information
lucasfcnunes committed Nov 3, 2024
1 parent 0198fc8 commit ae8a7b6
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions dbt/include/clickhouse/macros/materializations/table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,18 @@
{%- endmacro -%}

{% macro primary_key_clause(label) %}
{%- set primary_key = config.get('primary_key', validator=validation.any[basestring]) -%}
{%- set cols = config.get('primary_key', validator=validation.any[list, basestring]) -%}

{%- if primary_key is not none %}
{{ label }} {{ primary_key }}
{%- if cols is not none %}
{%- if cols is string -%}
{%- set cols = [cols] -%}
{%- endif -%}
{{ label }} (
{%- for item in cols -%}
{{ item }}
{%- if not loop.last -%},{%- endif -%}
{%- endfor -%}
)
{%- endif %}
{%- endmacro -%}

Expand Down

0 comments on commit ae8a7b6

Please sign in to comment.