Skip to content

Commit

Permalink
1.8.0 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
prdpsvs committed May 23, 2024
1 parent f7c84c7 commit 3e12635
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 23 deletions.
5 changes: 5 additions & 0 deletions dbt/include/synapse/macros/adapters/metadata.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{%- macro synapse__get_use_database_sql(database) -%}
{%- endmacro -%}

{% macro synapse__list_schemas(database) %}
{% call statement('list_schemas', fetch_result=True, auto_begin=False) -%}
select name as [schema]
Expand All @@ -8,6 +11,7 @@

{% macro synapse__list_relations_without_caching(schema_relation) %}
{% call statement('list_relations_without_caching', fetch_result=True) -%}
{{ get_use_database_sql(schema_relation.database) }}
select
table_catalog as [database],
table_name as [name],
Expand All @@ -26,6 +30,7 @@

{% macro synapse__get_relation_without_caching(schema_relation) -%}
{% call statement('list_relations_without_caching', fetch_result=True) -%}
{{ get_use_database_sql(schema_relation.database) }}
select
table_catalog as [database],
table_name as [name],
Expand Down
24 changes: 3 additions & 21 deletions dbt/include/synapse/macros/adapters/relation.sql
Original file line number Diff line number Diff line change
@@ -1,30 +1,12 @@
{% macro synapse__drop_relation(relation) -%}
{% call statement('drop_relation', auto_begin=False) -%}
{{ synapse__drop_relation_script(relation) }}
{%- endcall %}
{% endmacro %}

{% macro synapse__drop_relation_script(relation) -%}
{% if relation is not none %}
{% macro synapse__get_drop_sql(relation) -%}
{% if relation.type == 'view' or relation.type == 'materialized_view' -%}
{% set object_id_type = 'V' %}
{% elif relation.type == 'table'%}
{% set object_id_type = 'U' %}
{%- else -%} invalid target name
{% endif %}
if object_id ('{{ relation }}','{{ object_id_type }}') is not null
{% if relation.type == 'view' or relation.type == 'materialized_view' -%}
begin
drop view {{ relation }}
end
{% elif relation.type == 'table' %}
begin
drop {{ relation.type }} {{ relation }}
end
{% endif %}
{% else %}
-- no object to drop
select 1 as nothing
if object_id ('{{ relation }}','{{ object_id_type }}') is not null
drop {{ relation.type }} {{ relation }}
{% endif %}
{% endmacro %}

Expand Down
1 change: 1 addition & 0 deletions dbt/include/synapse/macros/adapters/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

{% macro synapse__create_schema_with_authorization(relation, schema_authorization) -%}
{% call statement('create_schema') -%}

IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = '{{ relation.schema }}')
BEGIN
EXEC('CREATE SCHEMA [{{ relation.schema }}] AUTHORIZATION [{{ schema_authorization }}]')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{% macro synapse__create_view_as(relation, sql) -%}

{%- set temp_view_sql = sql.replace("'", "''") -%}

{% set contract_config = config.get('contract') %}


{% if contract_config.enforced %}
{{ exceptions.warn("Model contracts cannot be enforced by <adapter>!") }}
{{ get_assert_columns_equivalent(sql) }}
Expand Down

0 comments on commit 3e12635

Please sign in to comment.