-
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 #241 from microsoft/correct-exclude-of-database
correct exclude of database
- Loading branch information
Showing
16 changed files
with
153 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version = "1.8.0rc1" | ||
version = "1.8.0rc2" |
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,5 @@ | ||
from dbt.adapters.synapse.relation_configs.policies import ( | ||
SynapseIncludePolicy, | ||
SynapseQuotePolicy, | ||
SynapseRelationType, | ||
) |
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,63 @@ | ||
from dataclasses import dataclass | ||
from typing import Any, Dict | ||
|
||
import agate | ||
from dbt.adapters.base.relation import Policy | ||
from dbt.adapters.contracts.relation import RelationConfig | ||
from dbt.adapters.relation_configs import RelationConfigBase, RelationResults | ||
|
||
from dbt.adapters.synapse.relation_configs.policies import SynapseIncludePolicy, SynapseQuotePolicy | ||
|
||
|
||
@dataclass(frozen=True, eq=True, unsafe_hash=True) | ||
class SynapseRelationConfigBase(RelationConfigBase): | ||
""" | ||
This base class implements a few boilerplate methods and provides some light structure for Synapse relations. | ||
""" | ||
|
||
@classmethod | ||
def include_policy(cls) -> Policy: | ||
return SynapseIncludePolicy() | ||
|
||
@classmethod | ||
def quote_policy(cls) -> Policy: | ||
return SynapseQuotePolicy() | ||
|
||
@classmethod | ||
def from_relation_config(cls, relation_config: RelationConfig): | ||
relation_config_dict = cls.parse_relation_config(relation_config) | ||
relation = cls.from_dict(relation_config_dict) | ||
return relation | ||
|
||
@classmethod | ||
def parse_relation_config(cls, relation_config: RelationConfig) -> Dict: | ||
raise NotImplementedError( | ||
"`parse_relation_config()` needs to be implemented on this RelationConfigBase instance" | ||
) | ||
|
||
@classmethod | ||
def from_relation_results(cls, relation_results: RelationResults): | ||
relation_config = cls.parse_relation_results(relation_results) | ||
relation = cls.from_dict(relation_config) | ||
return relation # type: ignore | ||
|
||
@classmethod | ||
def parse_relation_results(cls, relation_results: RelationResults) -> Dict[str, Any]: | ||
raise NotImplementedError( | ||
"`parse_relation_results()` needs to be implemented on this RelationConfigBase instance" | ||
) | ||
|
||
# @classmethod | ||
# def _render_part(cls, component: ComponentName, value: Optional[str]) -> Optional[str]: | ||
# if cls.include_policy().get_part(component) and value: | ||
# if cls.quote_policy().get_part(component): | ||
# return f"[{value}]" | ||
# return value.lower() | ||
# return None | ||
|
||
@classmethod | ||
def _get_first_row(cls, results: agate.Table) -> agate.Row: | ||
try: | ||
return results.rows[0] | ||
except IndexError: | ||
return agate.Row(values=set()) |
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.base.relation import Policy | ||
from dbt_common.dataclass_schema import StrEnum | ||
|
||
|
||
class SynapseRelationType(StrEnum): | ||
Table = "table" | ||
View = "view" | ||
CTE = "cte" | ||
MaterializedView = "materialized_view" | ||
|
||
|
||
@dataclass | ||
class SynapseIncludePolicy(Policy): | ||
database: bool = False | ||
schema: bool = True | ||
identifier: bool = True | ||
|
||
|
||
@dataclass | ||
class SynapseQuotePolicy(Policy): | ||
database: bool = True | ||
schema: bool = True | ||
identifier: bool = True |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from dataclasses import dataclass, field | ||
from typing import Optional, Type | ||
|
||
from dbt.adapters.base.relation import BaseRelation, Policy | ||
from dbt.adapters.utils import classproperty | ||
|
||
from dbt.adapters.synapse.relation_configs import SynapseIncludePolicy, SynapseQuotePolicy, SynapseRelationType | ||
|
||
|
||
@dataclass(frozen=True, eq=False, repr=False) | ||
class SynapseRelation(BaseRelation): | ||
type: Optional[SynapseRelationType] = None # type: ignore | ||
quote_policy: SynapseQuotePolicy = field(default_factory=lambda: SynapseQuotePolicy()) | ||
include_policy: Policy = field(default_factory=lambda: SynapseIncludePolicy()) | ||
|
||
@classproperty | ||
def get_relation_type(cls) -> Type[SynapseRelationType]: | ||
return SynapseRelationType | ||
|
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
7 changes: 0 additions & 7 deletions
7
.../synapse/macros/materializations/models/materialized_view/create_materialized_view_as.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
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