Skip to content
Merged
Changes from 1 commit
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
Next Next commit
create indexes
  • Loading branch information
stephennancekivell committed Dec 3, 2024
commit 29f2551780dc524d0880cb536efc6290e96307cd
14 changes: 13 additions & 1 deletion dbt/include/clickhouse/macros/materializations/table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@
{% if config.get('projections')%}
{{ projection_statement(relation) }}
{% endif %}

{% if config.get('indexes') %}
{{ indexes_statement(relation) }}
{% endif %}

{{ clickhouse__insert_into(relation, sql, has_contract) }}
{%- endif %}
Expand All @@ -169,6 +171,16 @@
{%- endfor %}
{%- endmacro %}

{% macro indexes_statement(relation) %}
{%- set indexes = config.get('indexes', default=[]) -%}

{%- for index in indexes %}
{% call statement('add_indexes') %}
ALTER TABLE {{ relation }} ADD INDEX {{ index.get('name') }} {{ index.get('definition') }}
{%endcall %}
{%- endfor %}
{%- endmacro %}

{% macro create_table_or_empty(temporary, relation, sql, has_contract) -%}
{%- set sql_header = config.get('sql_header', none) -%}

Expand Down