Skip to content

Commit

Permalink
added delta_table_replace materialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremynadal33 committed Aug 6, 2024
1 parent 726ae4c commit 85505d0
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{% materialization delta_table_replace, adapter='glue' %}
{%- set partition_by = config.get('partition_by', none) -%}
{%- set table_properties = config.get('table_properties', default={}) -%}
{% set lf_tags_config = config.get('lf_tags_config') -%}
{%- set lf_grants = config.get('lf_grants') -%}
{%- set target_relation = this -%}
{%- set build_sql = delta_create_or_replace(target_relation, table_properties) -%}

{{ run_hooks(pre_hooks) }}

{%- call statement('main') -%}
{{ build_sql }}
{%- endcall -%}

{% do persist_docs(target_relation, model) %}

{% do persist_constraints(target_relation, model) %}

{% if lf_tags_config is not none %}
{{ adapter.add_lf_tags(target_relation, lf_tags_config) }}
{% endif %}

{% if lf_grants is not none %}
{{ adapter.apply_lf_grants(target_relation, lf_grants) }}
{% endif %}

{{ run_hooks(post_hooks) }}

{{ return({'relations': [target_relation]}) }}

{% endmaterialization %}

{% macro delta_create_or_replace(relation, table_properties) %}
create or replace table {{ relation }}
using delta
{{ set_table_properties(table_properties) }}
{{ partition_cols(label="partitioned by") }}
{{ glue__location_clause(relation) }}
{{ comment_clause() }}
as
{{ sql }}
{% endmacro %}

0 comments on commit 85505d0

Please sign in to comment.