-
Notifications
You must be signed in to change notification settings - Fork 102
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 #513 from cody-scott/1.8-and-tests
DBT 1.8 and test coverage updates
- Loading branch information
Showing
94 changed files
with
3,728 additions
and
2,091 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
cp test.env.sample test.env | ||
|
||
pyenv install 3.10.7 | ||
pyenv virtualenv 3.10.7 dbt-sqlserver | ||
pyenv activate dbt-sqlserver | ||
docker compose build | ||
docker compose up -d | ||
|
||
make dev | ||
make server | ||
pip install -r dev_requirements.txt |
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 |
---|---|---|
|
@@ -96,3 +96,5 @@ ENV/ | |
env.bak/ | ||
venv.bak/ | ||
.mise.toml | ||
|
||
**devcontainer-lock.json** |
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.7.4" | ||
version = "1.8.0" |
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,13 @@ | ||
from dbt.adapters.sqlserver.relation_configs.policies import ( | ||
MAX_CHARACTERS_IN_IDENTIFIER, | ||
SQLServerIncludePolicy, | ||
SQLServerQuotePolicy, | ||
SQLServerRelationType, | ||
) | ||
|
||
__all__ = [ | ||
"MAX_CHARACTERS_IN_IDENTIFIER", | ||
"SQLServerIncludePolicy", | ||
"SQLServerQuotePolicy", | ||
"SQLServerRelationType", | ||
] |
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,25 @@ | ||
from dataclasses import dataclass | ||
|
||
from dbt.adapters.contracts.relation import Policy | ||
from dbt_common.dataclass_schema import StrEnum | ||
|
||
MAX_CHARACTERS_IN_IDENTIFIER = 127 | ||
|
||
|
||
class SQLServerRelationType(StrEnum): | ||
Table = "table" | ||
View = "view" | ||
CTE = "cte" | ||
|
||
|
||
class SQLServerIncludePolicy(Policy): | ||
database: bool = True | ||
schema: bool = True | ||
identifier: bool = True | ||
|
||
|
||
@dataclass | ||
class SQLServerQuotePolicy(Policy): | ||
database: bool = True | ||
schema: bool = True | ||
identifier: bool = True |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 @@ | ||
from typing import Optional | ||
|
||
import dbt.exceptions | ||
from dbt.adapters.base.impl import ConstraintSupport | ||
from dbt.adapters.fabric import FabricAdapter | ||
from dbt.contracts.graph.nodes import ConstraintType | ||
|
||
from dbt.adapters.sqlserver.sqlserver_column import SQLServerColumn | ||
from dbt.adapters.sqlserver.sqlserver_connections import SQLServerConnectionManager | ||
from dbt.adapters.sqlserver.sqlserver_relation import SQLServerRelation | ||
|
||
|
||
class SQLServerAdapter(FabricAdapter): | ||
""" | ||
Controls actual implmentation of adapter, and ability to override certain methods. | ||
""" | ||
|
||
ConnectionManager = SQLServerConnectionManager | ||
Column = SQLServerColumn | ||
Relation = SQLServerRelation | ||
|
||
CONSTRAINT_SUPPORT = { | ||
ConstraintType.check: ConstraintSupport.ENFORCED, | ||
ConstraintType.not_null: ConstraintSupport.ENFORCED, | ||
ConstraintType.unique: ConstraintSupport.ENFORCED, | ||
ConstraintType.primary_key: ConstraintSupport.ENFORCED, | ||
ConstraintType.foreign_key: ConstraintSupport.ENFORCED, | ||
} | ||
|
||
@classmethod | ||
def render_model_constraint(cls, constraint) -> Optional[str]: | ||
constraint_prefix = "add constraint " | ||
column_list = ", ".join(constraint.columns) | ||
|
||
if constraint.name is None: | ||
raise dbt.exceptions.DbtDatabaseError( | ||
"Constraint name cannot be empty. Provide constraint name - column " | ||
+ column_list | ||
+ " and run the project again." | ||
) | ||
|
||
if constraint.type == ConstraintType.unique: | ||
return constraint_prefix + f"{constraint.name} unique nonclustered({column_list})" | ||
elif constraint.type == ConstraintType.primary_key: | ||
return constraint_prefix + f"{constraint.name} primary key nonclustered({column_list})" | ||
elif constraint.type == ConstraintType.foreign_key and constraint.expression: | ||
return ( | ||
constraint_prefix | ||
+ f"{constraint.name} foreign key({column_list}) references " | ||
+ constraint.expression | ||
) | ||
elif constraint.type == ConstraintType.check and constraint.expression: | ||
return f"{constraint_prefix} {constraint.name} check ({constraint.expression})" | ||
elif constraint.type == ConstraintType.custom and constraint.expression: | ||
return f"{constraint_prefix} {constraint.name} {constraint.expression}" | ||
else: | ||
return None | ||
|
||
@classmethod | ||
def date_function(cls): | ||
return "getdate()" |
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,22 @@ | ||
from dbt.adapters.fabric import FabricColumn | ||
|
||
|
||
class SQLServerColumn(FabricColumn): | ||
def is_integer(self) -> bool: | ||
return self.dtype.lower() in [ | ||
# real types | ||
"smallint", | ||
"integer", | ||
"bigint", | ||
"smallserial", | ||
"serial", | ||
"bigserial", | ||
# aliases | ||
"int2", | ||
"int4", | ||
"int8", | ||
"serial2", | ||
"serial4", | ||
"serial8", | ||
"int", | ||
] |
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 |
---|---|---|
|
@@ -5,4 +5,4 @@ | |
|
||
@dataclass | ||
class SQLServerConfigs(FabricConfigs): | ||
... | ||
pass |
Oops, something went wrong.