Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ct-2198: Unify constraints and check_constraints fields #7130

Merged
merged 22 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4d47b27
ct-2198: clean up some type names and uses
peterallenwebb Mar 6, 2023
678c4a5
CT-2198: Unify constraints and constraints_check properties on columns
peterallenwebb Mar 9, 2023
8b352de
Make mypy version consistently 0.981 (#7134)
gshank Mar 7, 2023
95020ec
CT 1808 diff based partial parsing (#6873)
gshank Mar 7, 2023
ad470e7
model contracts on models materialized as views (#7120)
emmyoop Mar 7, 2023
15c327a
Create method for env var deprecation (#7086)
stu-k Mar 8, 2023
d00eb96
update to allow adapters to change model name resolution in py models…
colin-rogers-dbt Mar 8, 2023
5945b60
add env DBT_PROJECT_DIR support #6078 (#6659)
leo-schick Mar 9, 2023
27eeb5c
Add new index.html and changelog yaml files from dbt-docs (#7141)
FishtownBuildBot Mar 10, 2023
53f1471
Make version configs optional (#7060)
dave-connors-3 Mar 10, 2023
996cfa8
[CT-1584] New top level commands: interactive compile (#7008)
aranke Mar 11, 2023
4e46095
Merge remote-tracking branch 'origin/main' into paw/ct-2198-unify-con…
peterallenwebb Mar 14, 2023
d9d9b2a
CT-2198: Add changelog entry
peterallenwebb Mar 15, 2023
f0aadb8
Merge remote-tracking branch 'origin/main' into paw/ct-2198-unify-con…
peterallenwebb Mar 15, 2023
1e2b9cc
CT-2198: Fix tests which broke after merge
peterallenwebb Mar 15, 2023
f830081
CT-2198: Add explicit validation of constraint types w/ unit test
peterallenwebb Mar 16, 2023
618f8c5
CT-2198: Move access property, per code review
peterallenwebb Mar 17, 2023
6f188e6
CT-2198: Remove a redundant macro
peterallenwebb Mar 17, 2023
70a19d3
CT-1298: Rework constraints to be adapter-generated in Python code
peterallenwebb Mar 21, 2023
674084a
Merge remote-tracking branch 'origin/main' into paw/ct-2198-unify-con…
peterallenwebb Mar 21, 2023
ec31ebd
CT-2198: Clarify function name per review
peterallenwebb Mar 22, 2023
a09f912
Merge remote-tracking branch 'origin/main' into paw/ct-2198-unify-con…
peterallenwebb Mar 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions core/dbt/contracts/graph/unparsed.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Docs(dbtClassMixin, Replaceable):


@dataclass
class HasDocs(AdditionalPropertiesMixin, ExtensibleDbtClassMixin, Replaceable):
class HasColumnProps(AdditionalPropertiesMixin, ExtensibleDbtClassMixin, Replaceable):
peterallenwebb marked this conversation as resolved.
Show resolved Hide resolved
peterallenwebb marked this conversation as resolved.
Show resolved Hide resolved
peterallenwebb marked this conversation as resolved.
Show resolved Hide resolved
name: str
description: str = ""
meta: Dict[str, Any] = field(default_factory=dict)
Expand All @@ -104,7 +104,7 @@ class HasDocs(AdditionalPropertiesMixin, ExtensibleDbtClassMixin, Replaceable):


@dataclass
class HasTests(HasDocs):
class HasColumnAndTestProps(HasColumnProps):
mikealfare marked this conversation as resolved.
Show resolved Hide resolved
tests: Optional[List[TestDef]] = None

def __post_init__(self):
Expand All @@ -113,18 +113,18 @@ def __post_init__(self):


@dataclass
class UnparsedColumn(HasTests):
class UnparsedColumn(HasColumnAndTestProps):
quote: Optional[bool] = None
tags: List[str] = field(default_factory=list)


@dataclass
class HasColumnDocs(dbtClassMixin, Replaceable):
columns: Sequence[HasDocs] = field(default_factory=list)
columns: Sequence[HasColumnProps] = field(default_factory=list)


@dataclass
class HasColumnTests(HasColumnDocs):
class HasColumnTests(dbtClassMixin, Replaceable):
peterallenwebb marked this conversation as resolved.
Show resolved Hide resolved
columns: Sequence[UnparsedColumn] = field(default_factory=list)


Expand All @@ -145,12 +145,12 @@ class HasConfig:


@dataclass
class UnparsedAnalysisUpdate(HasConfig, HasColumnDocs, HasDocs, HasYamlMetadata):
class UnparsedAnalysisUpdate(HasConfig, HasColumnDocs, HasColumnProps, HasYamlMetadata):
peterallenwebb marked this conversation as resolved.
Show resolved Hide resolved
pass


@dataclass
class UnparsedNodeUpdate(HasConfig, HasColumnTests, HasTests, HasYamlMetadata):
class UnparsedNodeUpdate(HasConfig, HasColumnTests, HasColumnAndTestProps, HasYamlMetadata):
peterallenwebb marked this conversation as resolved.
Show resolved Hide resolved
quote_columns: Optional[bool] = None


Expand All @@ -162,7 +162,7 @@ class MacroArgument(dbtClassMixin):


@dataclass
class UnparsedMacroUpdate(HasConfig, HasDocs, HasYamlMetadata):
class UnparsedMacroUpdate(HasConfig, HasColumnProps, HasYamlMetadata):
peterallenwebb marked this conversation as resolved.
Show resolved Hide resolved
arguments: List[MacroArgument] = field(default_factory=list)


Expand Down Expand Up @@ -249,7 +249,7 @@ class Quoting(dbtClassMixin, Mergeable):


@dataclass
class UnparsedSourceTableDefinition(HasColumnTests, HasTests):
class UnparsedSourceTableDefinition(HasColumnTests, HasColumnAndTestProps):
peterallenwebb marked this conversation as resolved.
Show resolved Hide resolved
config: Dict[str, Any] = field(default_factory=dict)
loaded_at_field: Optional[str] = None
identifier: Optional[str] = None
Expand Down
29 changes: 8 additions & 21 deletions core/dbt/parser/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from dbt.contracts.graph.unparsed import (
HasColumnDocs,
HasColumnTests,
HasDocs,
HasColumnProps,
SourcePatch,
UnparsedAnalysisUpdate,
UnparsedColumn,
Expand Down Expand Up @@ -117,15 +117,7 @@ class ParserRef:
def __init__(self):
self.column_info: Dict[str, ColumnInfo] = {}

def add(
self,
column: Union[HasDocs, UnparsedColumn],
description: str,
data_type: Optional[str],
constraints: Optional[List[str]],
constraints_check: Optional[str],
meta: Dict[str, Any],
):
def _add(self, column: HasColumnProps):
peterallenwebb marked this conversation as resolved.
Show resolved Hide resolved
tags: List[str] = []
tags.extend(getattr(column, "tags", ()))
quote: Optional[bool]
Expand All @@ -135,11 +127,11 @@ def add(
quote = None
self.column_info[column.name] = ColumnInfo(
name=column.name,
description=description,
data_type=data_type,
constraints=constraints,
constraints_check=constraints_check,
meta=meta,
description=column.description,
data_type=column.data_type,
constraints=column.constraints,
constraints_check=column.constraints_check,
meta=column.meta,
tags=tags,
quote=quote,
_extra=column.extra,
Expand All @@ -149,12 +141,7 @@ def add(
def from_target(cls, target: Union[HasColumnDocs, HasColumnTests]) -> "ParserRef":
refs = cls()
for column in target.columns:
description = column.description
data_type = column.data_type
constraints = column.constraints
constraints_check = column.constraints_check
meta = column.meta
refs.add(column, description, data_type, constraints, constraints_check, meta)
refs._add(column)
peterallenwebb marked this conversation as resolved.
Show resolved Hide resolved
return refs


Expand Down