Skip to content

NOT NULL redshift constraint #38

@misteliy

Description

@misteliy

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions