diff --git a/dbt/include/fabric/macros/materializations/models/incremental/incremental.sql b/dbt/include/fabric/macros/materializations/models/incremental/incremental.sql index 797f09a..70a4025 100644 --- a/dbt/include/fabric/macros/materializations/models/incremental/incremental.sql +++ b/dbt/include/fabric/macros/materializations/models/incremental/incremental.sql @@ -3,7 +3,7 @@ {%- set full_refresh_mode = (should_full_refresh()) -%} {% set target_relation = this.incorporate(type='table') %} - {%- set relations_list = fabric__get_relation_without_caching(target_relation) -%} + {%- set relations_list = get_relation_without_caching(target_relation) -%} {%- set existing_relation = none %} {% if (relations_list|length == 1) and (relations_list[0][2] == target_relation.schema) @@ -14,9 +14,9 @@ {% set existing_relation = get_or_create_relation(relations_list[0][0], relations_list[0][2] , relations_list[0][1] , relations_list[0][3])[1] %} {% endif %} - {{ log("Full refresh mode" ~ full_refresh_mode)}} + {# {{ log("Full refresh mode" ~ full_refresh_mode)}} {{ log("existing relation : "~existing_relation ~ " type "~ existing_relation.type ~ " is view? "~existing_relation.is_view) }} - {{ log("target relation: " ~target_relation ~ " type "~ target_relation.type ~ " is view? "~target_relation.is_view) }} + {{ log("target relation: " ~target_relation ~ " type "~ target_relation.type ~ " is view? "~target_relation.is_view) }} #} -- configs {%- set unique_key = config.get('unique_key') -%} @@ -31,7 +31,7 @@ {% if existing_relation is none %} {%- call statement('main') -%} - {{ fabric__create_table_as(False, target_relation, sql)}} + {{ create_table_as(False, target_relation, sql)}} {%- endcall -%} {% elif existing_relation.is_view %} @@ -40,19 +40,19 @@ {{ log("Dropping relation " ~ target_relation ~ " because it is a view and this model is a table.") }} {{ drop_relation_if_exists(existing_relation) }} {%- call statement('main') -%} - {{ fabric__create_table_as(False, target_relation, sql)}} + {{ create_table_as(False, target_relation, sql)}} {%- endcall -%} {% elif full_refresh_mode %} {%- call statement('main') -%} - {{ fabric__create_table_as(False, target_relation, sql)}} + {{ create_table_as(False, target_relation, sql)}} {%- endcall -%} {% else %} {%- call statement('create_tmp_relation') -%} - {{ fabric__create_table_as(True, temp_relation, sql)}} + {{ create_table_as(True, temp_relation, sql)}} {%- endcall -%} {% do adapter.expand_target_column_types( from_relation=temp_relation, diff --git a/dbt/include/fabric/macros/materializations/models/table/clone.sql b/dbt/include/fabric/macros/materializations/models/table/clone.sql index 110dd03..b2e9d24 100644 --- a/dbt/include/fabric/macros/materializations/models/table/clone.sql +++ b/dbt/include/fabric/macros/materializations/models/table/clone.sql @@ -24,7 +24,7 @@ {%- set target_relation = this.incorporate(type='table') -%} {% call statement('main') %} - {{ fabric__drop_relation_script(target_relation) }} + {{ drop_relation_if_exists(target_relation) }} {{ create_or_replace_clone(target_relation, defer_relation) }} {% endcall %} {{ return({'relations': [target_relation]}) }} diff --git a/dbt/include/fabric/macros/materializations/models/table/create_table_as.sql b/dbt/include/fabric/macros/materializations/models/table/create_table_as.sql index 2ec9013..4db19c2 100644 --- a/dbt/include/fabric/macros/materializations/models/table/create_table_as.sql +++ b/dbt/include/fabric/macros/materializations/models/table/create_table_as.sql @@ -3,11 +3,11 @@ {% set tmp_relation = relation.incorporate( path={"identifier": relation.identifier.replace("#", "") ~ '_temp_view'}, type='view')-%} - {% do run_query(fabric__drop_relation_script(tmp_relation)) %} + {% do run_query(drop_relation_if_exists(tmp_relation)) %} {% set contract_config = config.get('contract') %} - {{ fabric__create_view_as(tmp_relation, sql) }} + {{ create_view_as(tmp_relation, sql) }} {% if contract_config.enforced %} CREATE TABLE [{{relation.database}}].[{{relation.schema}}].[{{relation.identifier}}] @@ -27,6 +27,6 @@ EXEC('CREATE TABLE [{{relation.database}}].[{{relation.schema}}].[{{relation.identifier}}] AS (SELECT * FROM [{{tmp_relation.database}}].[{{tmp_relation.schema}}].[{{tmp_relation.identifier}}]);'); {% endif %} - {{ fabric__drop_relation_script(tmp_relation) }} + {{ drop_relation_if_exists(tmp_relation) }} {% endmacro %} diff --git a/dbt/include/fabric/macros/materializations/models/view/view.sql b/dbt/include/fabric/macros/materializations/models/view/view.sql index 8576b2d..74011c2 100644 --- a/dbt/include/fabric/macros/materializations/models/view/view.sql +++ b/dbt/include/fabric/macros/materializations/models/view/view.sql @@ -3,15 +3,15 @@ {%- set target_relation = this.incorporate(type='view') -%} {{log("Target Relation "~target_relation)}} - {%- set relation = fabric__get_relation_without_caching(this) %} + {%- set relation = get_relation_without_caching(this) %} {% set existing_relation = none %} {% if (relation|length == 1) %} {% set existing_relation = get_or_create_relation(relation[0][0], relation[0][2] , relation[0][1] , relation[0][3])[1] %} {% endif %} - {{log("Existing Relation "~existing_relation)}} + {# {{log("Existing Relation "~existing_relation)}} #} {%- set backup_relation = none %} - {{log("Existing Relation type is "~ existing_relation.type)}} + {# {{log("Existing Relation type is "~ existing_relation.type)}} #} {% if (existing_relation != none and existing_relation.type == "table") %} {%- set backup_relation = make_backup_relation(target_relation, 'table') -%} {% elif (existing_relation != none and existing_relation.type == "view") %} diff --git a/dbt/include/fabric/macros/materializations/snapshots/helpers.sql b/dbt/include/fabric/macros/materializations/snapshots/helpers.sql index 58107d4..ca12361 100644 --- a/dbt/include/fabric/macros/materializations/snapshots/helpers.sql +++ b/dbt/include/fabric/macros/materializations/snapshots/helpers.sql @@ -190,7 +190,7 @@ {% macro build_snapshot_staging_table(strategy, temp_snapshot_relation, target_relation) %} {% set temp_relation = make_temp_relation(target_relation) %} - {% set select = fabric__snapshot_staging_table(strategy, temp_snapshot_relation, target_relation) %} + {% set select = snapshot_staging_table(strategy, temp_snapshot_relation, target_relation) %} {% call statement('build_snapshot_staging_relation') %} {{ create_table_as(True, temp_relation, select) }} {% endcall %} diff --git a/dbt/include/fabric/macros/materializations/snapshots/snapshot.sql b/dbt/include/fabric/macros/materializations/snapshots/snapshot.sql index 83e3f9b..039ae61 100644 --- a/dbt/include/fabric/macros/materializations/snapshots/snapshot.sql +++ b/dbt/include/fabric/macros/materializations/snapshots/snapshot.sql @@ -75,15 +75,13 @@ insert_cols = quoted_source_columns ) %} - {% endif %} {% call statement('main') %} {{ final_sql }} {% endcall %} - fabric__drop_relation_script(temp_snapshot_relation) - + {{ drop_relation_if_exists(temp_snapshot_relation) }} {% set should_revoke = should_revoke(target_relation_exists, full_refresh_mode=False) %} {% do apply_grants(target_relation, grant_config, should_revoke=should_revoke) %} @@ -94,7 +92,6 @@ {% endif %} {{ run_hooks(post_hooks, inside_transaction=True) }} - {{ adapter.commit() }} {% if staging_table is defined %} @@ -102,7 +99,6 @@ {% endif %} {{ run_hooks(post_hooks, inside_transaction=False) }} - {{ return({'relations': [target_relation]}) }} {% endmaterialization %}