Skip to content

Commit

Permalink
Set the table comment when creating the table
Browse files Browse the repository at this point in the history
This avoids a schema change in Iceberg when dbt does an:
```sql
comment on table sandbox.dbt_trino.rides is 'Combined table of NYC Taxi rides with the locations'
```
  • Loading branch information
Fokko committed Jun 30, 2023
1 parent a8309e9 commit db7eb96
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions dbt/include/trino/macros/adapters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@
{%- endif -%}
{%- endmacro -%}

{% macro comment(comment) %}
{%- if comment is not none and comment|length > 0 -%}
comment '{{ comment | replace("'", "''") }}'
{%- endif -%}
{%- endmacro -%}
{% macro trino__create_table_as(temporary, relation, sql) -%}
{%- set _properties = config.get('properties') -%}
Expand All @@ -100,6 +105,7 @@
{{ get_table_columns_and_constraints() }}
{{ get_assert_columns_equivalent(sql) }}
{%- set sql = get_select_subquery(sql) %}
{{ comment(model.get(''description'')) }}
{{ properties(_properties) }}
;
Expand All @@ -112,6 +118,7 @@
{%- else %}
create table {{ relation }}
{{ comment(model.get('description')) }}
{{ properties(_properties) }}
as (
{{ sql }}
Expand Down

0 comments on commit db7eb96

Please sign in to comment.