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

dbt Constraints #6233

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions core/dbt/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,17 @@ def __str__(self, prefix="! ") -> str:
)


# TODO: create a new class that displays in the terminal that a data type config is missing/wrong
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# TODO: create a new class that displays in the terminal that a data type config is missing/wrong
# TODO: create a new class that displays in the terminal that a data type config is missing/wrong. Test Comment

class UndefinedDataTypeException(CompilationException):
def __str__(self, prefix="! ") -> str:
msg = super().__str__(prefix)
return (
f"{msg}. This can happen when a data_type configuration does "
"not exist or is defined as null when `constraints_enabled: true` for a dbt model. \
Check for typos and/or verify data_type is defined for all columns for the dbt models with constraints. "
)


class UnknownAsyncIDException(Exception):
CODE = 10012
MESSAGE = "RPC server got an unknown async ID"
Expand Down
2 changes: 2 additions & 0 deletions core/dbt/parser/generic_test_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ def from_test_block(
)


# TODO: create a ConstraintsBuilder equivalent
class TestBuilder(Generic[Testable]):
"""An object to hold assorted test settings and perform basic parsing

Expand All @@ -194,6 +195,7 @@ class TestBuilder(Generic[Testable]):
r"((?P<test_namespace>([a-zA-Z_][0-9a-zA-Z_]*))\.)?"
r"(?P<test_name>([a-zA-Z_][0-9a-zA-Z_]*))"
)
# TODO: add config args like: "default", "data_type", "constraint", "check"
# args in the test entry representing test configs
CONFIG_ARGS = (
"severity",
Expand Down
1 change: 1 addition & 0 deletions core/dbt/parser/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def _trimmed(inp: str) -> str:
return inp[:44] + "..." + inp[-3:]


# TODO: I'll likely need to add a ConstraintsBuilder class similar to TestBuilder within SchemaParser
class SchemaParser(SimpleParser[GenericTestBlock, ParsedGenericTestNode]):
def __init__(
self,
Expand Down