-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #200 from microsoft/dependency_dbtsqlserver_to_dbt…
…fabric v1.4.1rc1 - switch dependency dbtsqlserver to dbtfabric (no fork)
- Loading branch information
Showing
20 changed files
with
249 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version = "1.4.0" | ||
version = "1.4.1rc1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,27 @@ | ||
from dbt.adapters.sqlserver import SQLServerAdapter | ||
from dbt.adapters.base.relation import BaseRelation | ||
from dbt.adapters.cache import _make_ref_key_msg | ||
from dbt.adapters.fabric import FabricAdapter | ||
from dbt.adapters.sql.impl import CREATE_SCHEMA_MACRO_NAME | ||
from dbt.events.functions import fire_event | ||
from dbt.events.types import SchemaCreation | ||
|
||
from dbt.adapters.synapse.synapse_connection_manager import SynapseConnectionManager | ||
|
||
|
||
class SynapseAdapter(SQLServerAdapter): | ||
class SynapseAdapter(FabricAdapter): | ||
ConnectionManager = SynapseConnectionManager | ||
|
||
def create_schema(self, relation: BaseRelation) -> None: | ||
relation = relation.without_identifier() | ||
fire_event(SchemaCreation(relation=_make_ref_key_msg(relation))) | ||
macro_name = CREATE_SCHEMA_MACRO_NAME | ||
kwargs = { | ||
"relation": relation, | ||
} | ||
|
||
if self.config.credentials.schema_authorization: | ||
kwargs["schema_authorization"] = self.config.credentials.schema_authorization | ||
macro_name = "synapse__create_schema_with_authorization" | ||
|
||
self.execute_macro(macro_name, kwargs=kwargs) | ||
self.commit_if_has_connection() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
from dbt.adapters.sqlserver import SQLServerConnectionManager | ||
from dbt.adapters.fabric import FabricConnectionManager | ||
|
||
|
||
class SynapseConnectionManager(SQLServerConnectionManager): | ||
class SynapseConnectionManager(FabricConnectionManager): | ||
TYPE = "synapse" | ||
TOKEN = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
from dataclasses import dataclass | ||
|
||
from dbt.adapters.sqlserver import SQLServerCredentials | ||
from dbt.adapters.fabric import FabricCredentials | ||
|
||
|
||
@dataclass | ||
class SynapseCredentials(SQLServerCredentials): | ||
class SynapseCredentials(FabricCredentials): | ||
@property | ||
def type(self): | ||
return "synapse" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
dbt/include/synapse/macros/materializations/snapshots/snapshot.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
{% macro synapse__create_columns(relation, columns) %} | ||
{# default__ macro uses "add column" | ||
TSQL preferes just "add" | ||
#} | ||
|
||
{% set columns %} | ||
{% for column in columns %} | ||
, CAST(NULL AS {{column.data_type}}) AS {{column_name}} | ||
{% endfor %} | ||
{% endset %} | ||
|
||
{% set tempTableName %} | ||
[{{relation.database}}].[{{ relation.schema }}].[{{ relation.identifier }}_{{ range(1300, 19000) | random }}] | ||
{% endset %} | ||
|
||
{%- set index = config.get('index', default="CLUSTERED COLUMNSTORE INDEX") -%} | ||
{%- set dist = config.get('dist', default="ROUND_ROBIN") -%} | ||
{% set tempTable %} | ||
CREATE TABLE {{tempTableName}} | ||
WITH( | ||
DISTRIBUTION = {{dist}}, | ||
{{index}} | ||
) | ||
AS SELECT * {{columns}} FROM [{{relation.database}}].[{{ relation.schema }}].[{{ relation.identifier }}] {{ information_schema_hints() }} | ||
{% endset %} | ||
|
||
{% call statement('create_temp_table') -%} | ||
{{ tempTable }} | ||
{%- endcall %} | ||
|
||
{% set dropTable %} | ||
DROP TABLE [{{relation.database}}].[{{ relation.schema }}].[{{ relation.identifier }}] | ||
{% endset %} | ||
|
||
{% call statement('drop_table') -%} | ||
{{ dropTable }} | ||
{%- endcall %} | ||
|
||
{%- set index = config.get('index', default="CLUSTERED COLUMNSTORE INDEX") -%} | ||
{%- set dist = config.get('dist', default="ROUND_ROBIN") -%} | ||
{% set createTable %} | ||
CREATE TABLE {{ relation }} | ||
WITH( | ||
DISTRIBUTION = {{dist}}, | ||
{{index}} | ||
) | ||
AS SELECT * FROM {{tempTableName}} {{ information_schema_hints() }} | ||
{% endset %} | ||
|
||
{% call statement('create_Table') -%} | ||
{{ createTable }} | ||
{%- endcall %} | ||
|
||
{% set dropTempTable %} | ||
DROP TABLE {{tempTableName}} | ||
{% endset %} | ||
|
||
{% call statement('drop_temp_table') -%} | ||
{{ dropTempTable }} | ||
{%- endcall %} | ||
{% endmacro %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.