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

NOT NULL redshift constraint #38

Open
misteliy opened this issue Nov 3, 2020 · 3 comments
Open

NOT NULL redshift constraint #38

misteliy opened this issue Nov 3, 2020 · 3 comments

Comments

@misteliy
Copy link

misteliy commented Nov 3, 2020

Describe the feature

not null constraints are enforced by redshift. Hence it would be good to have a mechanism to enable them within the dbt framework

Describe alternatives you've considered

we created a post-hook macro that looks something like this:
ALTER TABLE {{ this }} ADD COLUMN Temp varchar(32) not null default '';
UPDATE {{ this }} SET Temp = {{ column }};
ALTER TABLE {{ this }} DROP COLUMN {{ column }};
ALTER TABLE {{ this }} RENAME COLUMN Temp TO {{ column }};

Therefore creating a temp column, then copy, then drop the original and then rename. This is a very ugly hack and has also the problem that you need to specify a default value in the alter table command :/

Who will this benefit?

for all the redshift users it would be nice to leverage the constraint capabilities if enforced and hence this could be a nice add on.

@yummydum
Copy link

yummydum commented Oct 4, 2022

Are there plans for this feature?
It would be nice to have other constraints such as primary key and foreign key as well.

@ajaymalikbol
Copy link

Are there plans for this feature? It would be nice to have other constraints such as primary key and foreign key as well.

No

@misteliy
Copy link
Author

Hmm, I think these topics should be discussed in the bigger context of data contracts, otherwise the contract features won’t be really useful. I think there might also be options to rethink as contracts and dbt tests somewhat are doing overlapping activities. I would prefer to define contracts and tests in a unified way…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants